planck-v2 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of planck-v2 might be problematic. Click here for more details.
- package/LICENSE.txt +20 -0
- package/README.md +21 -0
- package/dist/planck-with-testbed.d.ts +4433 -0
- package/dist/planck-with-testbed.js +20730 -0
- package/dist/planck-with-testbed.js.map +1 -0
- package/dist/planck-with-testbed.umd.cjs +20730 -0
- package/dist/planck-with-testbed.umd.cjs.map +1 -0
- package/dist/planck.d.ts +4343 -0
- package/dist/planck.js +13516 -0
- package/dist/planck.js.map +1 -0
- package/dist/planck.umd.cjs +13516 -0
- package/dist/planck.umd.cjs.map +1 -0
- package/package.json +105 -0
- package/src/Settings.ts +238 -0
- package/src/__test__/Basic.test.ts +43 -0
- package/src/__test__/CCD.test.ts +70 -0
- package/src/__test__/Collision.test.ts +133 -0
- package/src/__test__/Math.test.ts +105 -0
- package/src/__test__/Pool.test.ts +48 -0
- package/src/__test__/World.test.ts +73 -0
- package/src/collision/AABB.ts +287 -0
- package/src/collision/BroadPhase.ts +210 -0
- package/src/collision/Distance.ts +962 -0
- package/src/collision/DynamicTree.ts +907 -0
- package/src/collision/Manifold.ts +420 -0
- package/src/collision/Raycast.ts +30 -0
- package/src/collision/Shape.ts +114 -0
- package/src/collision/TimeOfImpact.ts +502 -0
- package/src/collision/shape/BoxShape.ts +34 -0
- package/src/collision/shape/ChainShape.ts +360 -0
- package/src/collision/shape/CircleShape.ts +202 -0
- package/src/collision/shape/CollideCircle.ts +66 -0
- package/src/collision/shape/CollideCirclePolygon.ts +142 -0
- package/src/collision/shape/CollideEdgeCircle.ts +185 -0
- package/src/collision/shape/CollideEdgePolygon.ts +528 -0
- package/src/collision/shape/CollidePolygon.ts +280 -0
- package/src/collision/shape/EdgeShape.ts +316 -0
- package/src/collision/shape/PolygonShape.ts +581 -0
- package/src/common/Geo.ts +589 -0
- package/src/common/Jacobian.ts +17 -0
- package/src/common/Mat22.ts +221 -0
- package/src/common/Mat33.ts +224 -0
- package/src/common/Math.ts +96 -0
- package/src/common/Rot.ts +218 -0
- package/src/common/Sweep.ts +119 -0
- package/src/common/Transform.ts +203 -0
- package/src/common/Vec2.ts +624 -0
- package/src/common/Vec3.ts +188 -0
- package/src/dynamics/Body.ts +1198 -0
- package/src/dynamics/Contact.ts +1366 -0
- package/src/dynamics/Fixture.ts +506 -0
- package/src/dynamics/Joint.ts +226 -0
- package/src/dynamics/Position.ts +44 -0
- package/src/dynamics/Solver.ts +890 -0
- package/src/dynamics/Velocity.ts +18 -0
- package/src/dynamics/World.ts +1169 -0
- package/src/dynamics/joint/DistanceJoint.ts +463 -0
- package/src/dynamics/joint/FrictionJoint.ts +396 -0
- package/src/dynamics/joint/GearJoint.ts +591 -0
- package/src/dynamics/joint/MotorJoint.ts +430 -0
- package/src/dynamics/joint/MouseJoint.ts +390 -0
- package/src/dynamics/joint/PrismaticJoint.ts +903 -0
- package/src/dynamics/joint/PulleyJoint.ts +529 -0
- package/src/dynamics/joint/RevoluteJoint.ts +745 -0
- package/src/dynamics/joint/RopeJoint.ts +383 -0
- package/src/dynamics/joint/WeldJoint.ts +544 -0
- package/src/dynamics/joint/WheelJoint.ts +683 -0
- package/src/dynamics/joint/__test__/DistanceJoint.test.ts +66 -0
- package/src/index.ts +60 -0
- package/src/internal.ts +20 -0
- package/src/main.ts +3 -0
- package/src/serializer/__test__/Serialize.test.ts +52 -0
- package/src/serializer/__test__/Validator.test.ts +55 -0
- package/src/serializer/index.ts +257 -0
- package/src/serializer/schema.json +168 -0
- package/src/util/Pool.ts +120 -0
- package/src/util/Testbed.ts +157 -0
- package/src/util/Timer.ts +15 -0
- package/src/util/options.ts +28 -0
- package/src/util/stats.ts +26 -0
package/dist/planck.d.ts
ADDED
|
@@ -0,0 +1,4343 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
/** 2D vector */
|
|
4
|
+
export interface Vec2Value {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 2D vector
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Use Vec2Value and geo functions instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Vec2 {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
constructor(x: number, y: number);
|
|
17
|
+
constructor(obj: Vec2Value);
|
|
18
|
+
constructor();
|
|
19
|
+
/** @hidden */
|
|
20
|
+
_serialize(): object;
|
|
21
|
+
/** @hidden */
|
|
22
|
+
static _deserialize(data: any): Vec2;
|
|
23
|
+
static zero(): Vec2;
|
|
24
|
+
/** @hidden */
|
|
25
|
+
static neo(x: number, y: number): Vec2;
|
|
26
|
+
static clone(v: Vec2Value): Vec2;
|
|
27
|
+
/** @hidden */
|
|
28
|
+
toString(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Does this vector contain finite coordinates?
|
|
31
|
+
*/
|
|
32
|
+
static isValid(obj: any): boolean;
|
|
33
|
+
static assert(o: any): void;
|
|
34
|
+
clone(): Vec2;
|
|
35
|
+
/**
|
|
36
|
+
* Set this vector to all zeros.
|
|
37
|
+
*
|
|
38
|
+
* @returns this
|
|
39
|
+
*/
|
|
40
|
+
setZero(): Vec2;
|
|
41
|
+
set(x: number, y: number): Vec2;
|
|
42
|
+
set(value: Vec2Value): Vec2;
|
|
43
|
+
/**
|
|
44
|
+
* Set this vector to some specified coordinates.
|
|
45
|
+
*
|
|
46
|
+
* @returns this
|
|
47
|
+
*/
|
|
48
|
+
setNum(x: number, y: number): this;
|
|
49
|
+
/**
|
|
50
|
+
* Set this vector to some specified coordinates.
|
|
51
|
+
*
|
|
52
|
+
* @returns this
|
|
53
|
+
*/
|
|
54
|
+
setVec2(value: Vec2Value): this;
|
|
55
|
+
/**
|
|
56
|
+
* Set linear combination of v and w: `a * v + b * w`
|
|
57
|
+
*/
|
|
58
|
+
setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2;
|
|
59
|
+
setMul(a: number, v: Vec2Value): Vec2;
|
|
60
|
+
/**
|
|
61
|
+
* Add a vector to this vector.
|
|
62
|
+
*
|
|
63
|
+
* @returns this
|
|
64
|
+
*/
|
|
65
|
+
add(w: Vec2Value): Vec2;
|
|
66
|
+
/**
|
|
67
|
+
* Add linear combination of v and w: `a * v + b * w`
|
|
68
|
+
*/
|
|
69
|
+
addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2;
|
|
70
|
+
addMul(a: number, v: Vec2Value): Vec2;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use subCombine or subMul
|
|
73
|
+
*/
|
|
74
|
+
wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2;
|
|
75
|
+
/**
|
|
76
|
+
* Subtract linear combination of v and w: `a * v + b * w`
|
|
77
|
+
*/
|
|
78
|
+
subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2;
|
|
79
|
+
subMul(a: number, v: Vec2Value): Vec2;
|
|
80
|
+
/**
|
|
81
|
+
* Subtract a vector from this vector
|
|
82
|
+
*
|
|
83
|
+
* @returns this
|
|
84
|
+
*/
|
|
85
|
+
sub(w: Vec2Value): Vec2;
|
|
86
|
+
/**
|
|
87
|
+
* Multiply this vector by a scalar.
|
|
88
|
+
*
|
|
89
|
+
* @returns this
|
|
90
|
+
*/
|
|
91
|
+
mul(m: number): Vec2;
|
|
92
|
+
/**
|
|
93
|
+
* Get the length of this vector (the norm).
|
|
94
|
+
*
|
|
95
|
+
* For performance, use this instead of lengthSquared (if possible).
|
|
96
|
+
*/
|
|
97
|
+
length(): number;
|
|
98
|
+
/**
|
|
99
|
+
* Get the length squared.
|
|
100
|
+
*/
|
|
101
|
+
lengthSquared(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Convert this vector into a unit vector.
|
|
104
|
+
*
|
|
105
|
+
* @returns old length
|
|
106
|
+
*/
|
|
107
|
+
normalize(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Returns a new unit vector from the provided vector.
|
|
110
|
+
*
|
|
111
|
+
* @returns new unit vector
|
|
112
|
+
*/
|
|
113
|
+
static normalize(v: Vec2Value): Vec2;
|
|
114
|
+
/**
|
|
115
|
+
* Get the length of this vector (the norm).
|
|
116
|
+
*
|
|
117
|
+
* For performance, use this instead of lengthSquared (if possible).
|
|
118
|
+
*/
|
|
119
|
+
static lengthOf(v: Vec2Value): number;
|
|
120
|
+
/**
|
|
121
|
+
* Get the length squared.
|
|
122
|
+
*/
|
|
123
|
+
static lengthSquared(v: Vec2Value): number;
|
|
124
|
+
static distance(v: Vec2Value, w: Vec2Value): number;
|
|
125
|
+
static distanceSquared(v: Vec2Value, w: Vec2Value): number;
|
|
126
|
+
static areEqual(v: Vec2Value, w: Vec2Value): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
|
|
129
|
+
*/
|
|
130
|
+
static skew(v: Vec2Value): Vec2;
|
|
131
|
+
/** Dot product on two vectors */
|
|
132
|
+
static dot(v: Vec2Value, w: Vec2Value): number;
|
|
133
|
+
/** Cross product between two vectors */
|
|
134
|
+
static cross(v: Vec2Value, w: Vec2Value): number;
|
|
135
|
+
/** Cross product between a vector and a scalar */
|
|
136
|
+
static cross(v: Vec2Value, w: number): Vec2;
|
|
137
|
+
/** Cross product between a scalar and a vector */
|
|
138
|
+
static cross(v: number, w: Vec2Value): Vec2;
|
|
139
|
+
/** Cross product on two vectors */
|
|
140
|
+
static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number;
|
|
141
|
+
/** Cross product on a vector and a scalar */
|
|
142
|
+
static crossVec2Num(v: Vec2Value, w: number): Vec2;
|
|
143
|
+
/** Cross product on a vector and a scalar */
|
|
144
|
+
static crossNumVec2(v: number, w: Vec2Value): Vec2;
|
|
145
|
+
/** Returns `a + (v x w)` */
|
|
146
|
+
static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;
|
|
147
|
+
/** Returns `a + (v x w)` */
|
|
148
|
+
static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;
|
|
149
|
+
/**
|
|
150
|
+
* Returns `a + (v x w)`
|
|
151
|
+
*/
|
|
152
|
+
static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2;
|
|
153
|
+
/**
|
|
154
|
+
* Returns `a + (v x w)`
|
|
155
|
+
*/
|
|
156
|
+
static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2;
|
|
157
|
+
static add(v: Vec2Value, w: Vec2Value): Vec2;
|
|
158
|
+
/** @hidden @deprecated */
|
|
159
|
+
static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2;
|
|
160
|
+
static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2;
|
|
161
|
+
static sub(v: Vec2Value, w: Vec2Value): Vec2;
|
|
162
|
+
static mul(a: Vec2Value, b: number): Vec2;
|
|
163
|
+
static mul(a: number, b: Vec2Value): Vec2;
|
|
164
|
+
static mulVec2Num(a: Vec2Value, b: number): Vec2;
|
|
165
|
+
static mulNumVec2(a: number, b: Vec2Value): Vec2;
|
|
166
|
+
neg(): Vec2;
|
|
167
|
+
static neg(v: Vec2Value): Vec2;
|
|
168
|
+
static abs(v: Vec2Value): Vec2;
|
|
169
|
+
static mid(v: Vec2Value, w: Vec2Value): Vec2;
|
|
170
|
+
static upper(v: Vec2Value, w: Vec2Value): Vec2;
|
|
171
|
+
static lower(v: Vec2Value, w: Vec2Value): Vec2;
|
|
172
|
+
clamp(max: number): Vec2;
|
|
173
|
+
static clamp(v: Vec2Value, max: number): Vec2;
|
|
174
|
+
/** @hidden */
|
|
175
|
+
static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value;
|
|
176
|
+
/** @hidden @deprecated */
|
|
177
|
+
static scaleFn(x: number, y: number): (v: Vec2Value) => Vec2;
|
|
178
|
+
/** @hidden @deprecated */
|
|
179
|
+
static translateFn(x: number, y: number): (v: Vec2Value) => Vec2;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Rotation
|
|
183
|
+
*/
|
|
184
|
+
export interface RotValue {
|
|
185
|
+
/** sin(angle) */
|
|
186
|
+
s: number;
|
|
187
|
+
/** cos(angle) */
|
|
188
|
+
c: number;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Rotation
|
|
192
|
+
*
|
|
193
|
+
* @deprecated Use RotValue and geo functions instead.
|
|
194
|
+
* */
|
|
195
|
+
export declare class Rot {
|
|
196
|
+
/** sin(angle) */
|
|
197
|
+
s: number;
|
|
198
|
+
/** cos(angle) */
|
|
199
|
+
c: number;
|
|
200
|
+
/** Initialize from an angle in radians. */
|
|
201
|
+
constructor(angle?: number | RotValue);
|
|
202
|
+
/** @hidden */
|
|
203
|
+
static neo(angle: number): Rot;
|
|
204
|
+
static clone(rot: RotValue): Rot;
|
|
205
|
+
static identity(): Rot;
|
|
206
|
+
static isValid(obj: any): boolean;
|
|
207
|
+
static assert(o: any): void;
|
|
208
|
+
/** Set to the identity rotation. */
|
|
209
|
+
setIdentity(): void;
|
|
210
|
+
set(angle: number | RotValue): void;
|
|
211
|
+
setRot(angle: RotValue): void;
|
|
212
|
+
/** Set using an angle in radians. */
|
|
213
|
+
setAngle(angle: number): void;
|
|
214
|
+
/** Get the angle in radians. */
|
|
215
|
+
getAngle(): number;
|
|
216
|
+
/** Get the x-axis. */
|
|
217
|
+
getXAxis(): Vec2;
|
|
218
|
+
/** Get the y-axis. */
|
|
219
|
+
getYAxis(): Vec2;
|
|
220
|
+
/** Multiply two rotations: q * r */
|
|
221
|
+
static mul(rot: RotValue, m: RotValue): Rot;
|
|
222
|
+
/** Rotate a vector */
|
|
223
|
+
static mul(rot: RotValue, m: Vec2Value): Vec2;
|
|
224
|
+
/** Multiply two rotations: q * r */
|
|
225
|
+
static mulRot(rot: RotValue, m: RotValue): Rot;
|
|
226
|
+
/** Rotate a vector */
|
|
227
|
+
static mulVec2(rot: RotValue, m: Vec2Value): Vec2;
|
|
228
|
+
static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2;
|
|
229
|
+
/** Transpose multiply two rotations: qT * r */
|
|
230
|
+
static mulT(rot: RotValue, m: RotValue): Rot;
|
|
231
|
+
/** Inverse rotate a vector */
|
|
232
|
+
static mulT(rot: RotValue, m: Vec2Value): Vec2;
|
|
233
|
+
/** Transpose multiply two rotations: qT * r */
|
|
234
|
+
static mulTRot(rot: RotValue, m: RotValue): Rot;
|
|
235
|
+
/** Inverse rotate a vector */
|
|
236
|
+
static mulTVec2(rot: RotValue, m: Vec2Value): Vec2;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A transform contains translation and rotation. It is used to represent the
|
|
240
|
+
* position and orientation of rigid frames. Initialize using a position vector
|
|
241
|
+
* and a rotation.
|
|
242
|
+
*/
|
|
243
|
+
export interface TransformValue {
|
|
244
|
+
p: Vec2Value;
|
|
245
|
+
q: RotValue;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A transform contains translation and rotation. It is used to represent the
|
|
249
|
+
* position and orientation of rigid frames. Initialize using a position vector
|
|
250
|
+
* and a rotation.
|
|
251
|
+
*
|
|
252
|
+
* @deprecated Use TransformValue and geo functions instead.
|
|
253
|
+
*/
|
|
254
|
+
export declare class Transform {
|
|
255
|
+
/** position */
|
|
256
|
+
p: Vec2;
|
|
257
|
+
/** rotation */
|
|
258
|
+
q: Rot;
|
|
259
|
+
constructor(position?: Vec2Value, rotation?: number);
|
|
260
|
+
static clone(xf: Transform): Transform;
|
|
261
|
+
/** @hidden */
|
|
262
|
+
static neo(position: Vec2Value, rotation: Rot): Transform;
|
|
263
|
+
static identity(): Transform;
|
|
264
|
+
/** Set this to the identity transform */
|
|
265
|
+
setIdentity(): void;
|
|
266
|
+
/** Set position and angle */
|
|
267
|
+
set(position: Vec2Value, rotation: number): void;
|
|
268
|
+
/** Copy from another transform */
|
|
269
|
+
set(xf: TransformValue): void;
|
|
270
|
+
/** Set position and angle */
|
|
271
|
+
setNum(position: Vec2Value, rotation: number): void;
|
|
272
|
+
setTransform(xf: TransformValue): void;
|
|
273
|
+
static isValid(obj: any): boolean;
|
|
274
|
+
static assert(o: any): void;
|
|
275
|
+
static mul(a: TransformValue, b: Vec2Value): Vec2;
|
|
276
|
+
static mul(a: TransformValue, b: TransformValue): Transform;
|
|
277
|
+
static mulAll(a: Transform, b: Vec2Value[]): Vec2[];
|
|
278
|
+
static mulAll(a: Transform, b: Transform[]): Transform[];
|
|
279
|
+
/** @hidden @deprecated */
|
|
280
|
+
static mulFn(a: TransformValue): (b: Vec2Value) => Vec2;
|
|
281
|
+
static mulVec2(a: TransformValue, b: Vec2Value): Vec2;
|
|
282
|
+
static mulXf(a: TransformValue, b: TransformValue): Transform;
|
|
283
|
+
static mulT(a: TransformValue, b: Vec2Value): Vec2;
|
|
284
|
+
static mulT(a: TransformValue, b: TransformValue): Transform;
|
|
285
|
+
static mulTVec2(a: TransformValue, b: Vec2Value): Vec2;
|
|
286
|
+
static mulTXf(a: TransformValue, b: TransformValue): Transform;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.
|
|
290
|
+
*/
|
|
291
|
+
export interface RayCastInput {
|
|
292
|
+
p1: Vec2Value;
|
|
293
|
+
p2: Vec2Value;
|
|
294
|
+
maxFraction: number;
|
|
295
|
+
}
|
|
296
|
+
export type RayCastCallback = (subInput: RayCastInput, id: number) => number;
|
|
297
|
+
/**
|
|
298
|
+
* Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,
|
|
299
|
+
* where `p1` and `p2` come from RayCastInput.
|
|
300
|
+
*/
|
|
301
|
+
export interface RayCastOutput {
|
|
302
|
+
normal: Vec2Value;
|
|
303
|
+
fraction: number;
|
|
304
|
+
}
|
|
305
|
+
/** Axis-aligned bounding box */
|
|
306
|
+
export interface AABBValue {
|
|
307
|
+
lowerBound: Vec2Value;
|
|
308
|
+
upperBound: Vec2Value;
|
|
309
|
+
}
|
|
310
|
+
/** Axis-aligned bounding box */
|
|
311
|
+
export declare class AABB {
|
|
312
|
+
lowerBound: Vec2Value;
|
|
313
|
+
upperBound: Vec2Value;
|
|
314
|
+
constructor(lower?: Vec2Value, upper?: Vec2Value);
|
|
315
|
+
/**
|
|
316
|
+
* Verify that the bounds are sorted.
|
|
317
|
+
*/
|
|
318
|
+
isValid(): boolean;
|
|
319
|
+
static isValid(obj: any): boolean;
|
|
320
|
+
static assert(o: any): void;
|
|
321
|
+
/**
|
|
322
|
+
* Get the center of the AABB.
|
|
323
|
+
*/
|
|
324
|
+
getCenter(): Vec2Value;
|
|
325
|
+
/**
|
|
326
|
+
* Get the extents of the AABB (half-widths).
|
|
327
|
+
*/
|
|
328
|
+
getExtents(): Vec2Value;
|
|
329
|
+
/**
|
|
330
|
+
* Get the perimeter length.
|
|
331
|
+
*/
|
|
332
|
+
getPerimeter(): number;
|
|
333
|
+
/**
|
|
334
|
+
* Combine one or two AABB into this one.
|
|
335
|
+
*/
|
|
336
|
+
combine(a: AABBValue, b?: AABBValue): void;
|
|
337
|
+
combinePoints(a: Vec2Value, b: Vec2Value): void;
|
|
338
|
+
set(aabb: AABBValue): void;
|
|
339
|
+
contains(aabb: AABBValue): boolean;
|
|
340
|
+
extend(value: number): AABB;
|
|
341
|
+
static extend(out: AABBValue, value: number): AABBValue;
|
|
342
|
+
static testOverlap(a: AABBValue, b: AABBValue): boolean;
|
|
343
|
+
static areEqual(a: AABBValue, b: AABBValue): boolean;
|
|
344
|
+
static diff(a: AABBValue, b: AABBValue): number;
|
|
345
|
+
rayCast(output: RayCastOutput, input: RayCastInput): boolean;
|
|
346
|
+
/** @hidden */
|
|
347
|
+
toString(): string;
|
|
348
|
+
static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue;
|
|
349
|
+
static combinedPerimeter(a: AABBValue, b: AABBValue): number;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Input for Distance. You have to option to use the shape radii in the
|
|
353
|
+
* computation. Even
|
|
354
|
+
*/
|
|
355
|
+
export declare class DistanceInput {
|
|
356
|
+
readonly proxyA: DistanceProxy;
|
|
357
|
+
readonly proxyB: DistanceProxy;
|
|
358
|
+
readonly transformA: TransformValue;
|
|
359
|
+
readonly transformB: TransformValue;
|
|
360
|
+
useRadii: boolean;
|
|
361
|
+
recycle(): void;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Output for Distance.
|
|
365
|
+
*/
|
|
366
|
+
export declare class DistanceOutput {
|
|
367
|
+
/** closest point on shapeA */
|
|
368
|
+
pointA: Vec2Value;
|
|
369
|
+
/** closest point on shapeB */
|
|
370
|
+
pointB: Vec2Value;
|
|
371
|
+
distance: number;
|
|
372
|
+
/** iterations number of GJK iterations used */
|
|
373
|
+
iterations: number;
|
|
374
|
+
recycle(): void;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Used to warm start Distance. Set count to zero on first call.
|
|
378
|
+
*/
|
|
379
|
+
export declare class SimplexCache {
|
|
380
|
+
/** length or area */
|
|
381
|
+
metric: number;
|
|
382
|
+
/** vertices on shape A */
|
|
383
|
+
indexA: number[];
|
|
384
|
+
/** vertices on shape B */
|
|
385
|
+
indexB: number[];
|
|
386
|
+
count: number;
|
|
387
|
+
recycle(): void;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Compute the closest points between two shapes. Supports any combination of:
|
|
391
|
+
* CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On
|
|
392
|
+
* the first call set SimplexCache.count to zero.
|
|
393
|
+
*/
|
|
394
|
+
export declare const Distance: {
|
|
395
|
+
(output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void;
|
|
396
|
+
testOverlap: (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue) => boolean;
|
|
397
|
+
Input: typeof DistanceInput;
|
|
398
|
+
Output: typeof DistanceOutput;
|
|
399
|
+
Proxy: typeof DistanceProxy;
|
|
400
|
+
Cache: typeof SimplexCache;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* A distance proxy is used by the GJK algorithm. It encapsulates any shape.
|
|
404
|
+
*/
|
|
405
|
+
export declare class DistanceProxy {
|
|
406
|
+
recycle(): void;
|
|
407
|
+
/**
|
|
408
|
+
* Get the vertex count.
|
|
409
|
+
*/
|
|
410
|
+
getVertexCount(): number;
|
|
411
|
+
/**
|
|
412
|
+
* Get a vertex by index. Used by Distance.
|
|
413
|
+
*/
|
|
414
|
+
getVertex(index: number): Vec2Value;
|
|
415
|
+
/**
|
|
416
|
+
* Get the supporting vertex index in the given direction.
|
|
417
|
+
*/
|
|
418
|
+
getSupport(d: Vec2Value): number;
|
|
419
|
+
/**
|
|
420
|
+
* Get the supporting vertex in the given direction.
|
|
421
|
+
*/
|
|
422
|
+
getSupportVertex(d: Vec2Value): Vec2Value;
|
|
423
|
+
/**
|
|
424
|
+
* Initialize the proxy using the given shape. The shape must remain in scope
|
|
425
|
+
* while the proxy is in use.
|
|
426
|
+
*/
|
|
427
|
+
set(shape: Shape, index: number): void;
|
|
428
|
+
/**
|
|
429
|
+
* Initialize the proxy using a vertex cloud and radius. The vertices
|
|
430
|
+
* must remain in scope while the proxy is in use.
|
|
431
|
+
*/
|
|
432
|
+
setVertices(vertices: Vec2Value[], count: number, radius: number): void;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Determine if two generic shapes overlap.
|
|
436
|
+
*/
|
|
437
|
+
export declare const testOverlap: (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue) => boolean;
|
|
438
|
+
/**
|
|
439
|
+
* Input parameters for ShapeCast
|
|
440
|
+
*/
|
|
441
|
+
export declare class ShapeCastInput {
|
|
442
|
+
readonly proxyA: DistanceProxy;
|
|
443
|
+
readonly proxyB: DistanceProxy;
|
|
444
|
+
readonly transformA: TransformValue;
|
|
445
|
+
readonly transformB: TransformValue;
|
|
446
|
+
readonly translationB: Vec2Value;
|
|
447
|
+
recycle(): void;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Output results for b2ShapeCast
|
|
451
|
+
*/
|
|
452
|
+
export declare class ShapeCastOutput {
|
|
453
|
+
point: Vec2Value;
|
|
454
|
+
normal: Vec2Value;
|
|
455
|
+
lambda: number;
|
|
456
|
+
iterations: number;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Perform a linear shape cast of shape B moving and shape A fixed. Determines
|
|
460
|
+
* the hit point, normal, and translation fraction.
|
|
461
|
+
*
|
|
462
|
+
* @returns true if hit, false if there is no hit or an initial overlap
|
|
463
|
+
*/
|
|
464
|
+
export declare const ShapeCast: (output: ShapeCastOutput, input: ShapeCastInput) => boolean;
|
|
465
|
+
/**
|
|
466
|
+
* A joint edge is used to connect bodies and joints together in a joint graph
|
|
467
|
+
* where each body is a node and each joint is an edge. A joint edge belongs to
|
|
468
|
+
* a doubly linked list maintained in each attached body. Each joint has two
|
|
469
|
+
* joint nodes, one for each attached body.
|
|
470
|
+
*/
|
|
471
|
+
export declare class JointEdge {
|
|
472
|
+
/**
|
|
473
|
+
* provides quick access to the other body attached.
|
|
474
|
+
*/
|
|
475
|
+
other: Body$1 | null;
|
|
476
|
+
/**
|
|
477
|
+
* the joint
|
|
478
|
+
*/
|
|
479
|
+
joint: Joint | null;
|
|
480
|
+
/**
|
|
481
|
+
* prev the previous joint edge in the body's joint list
|
|
482
|
+
*/
|
|
483
|
+
prev: JointEdge | null;
|
|
484
|
+
/**
|
|
485
|
+
* the next joint edge in the body's joint list
|
|
486
|
+
*/
|
|
487
|
+
next: JointEdge | null;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Joint definitions are used to construct joints.
|
|
491
|
+
*/
|
|
492
|
+
export interface JointOpt {
|
|
493
|
+
/**
|
|
494
|
+
* Use this to attach application specific data to your joints.
|
|
495
|
+
*/
|
|
496
|
+
userData?: any;
|
|
497
|
+
/**
|
|
498
|
+
* Set this flag to true if the attached bodies
|
|
499
|
+
* should collide.
|
|
500
|
+
*/
|
|
501
|
+
collideConnected?: boolean;
|
|
502
|
+
/** Styling for dev-tools. */
|
|
503
|
+
style?: Style;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Joint definitions are used to construct joints.
|
|
507
|
+
*/
|
|
508
|
+
export interface JointDef extends JointOpt {
|
|
509
|
+
/**
|
|
510
|
+
* The first attached body.
|
|
511
|
+
*/
|
|
512
|
+
bodyA: Body$1;
|
|
513
|
+
/**
|
|
514
|
+
* The second attached body.
|
|
515
|
+
*/
|
|
516
|
+
bodyB: Body$1;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* The base joint class. Joints are used to constraint two bodies together in
|
|
520
|
+
* various fashions. Some joints also feature limits and motors.
|
|
521
|
+
*/
|
|
522
|
+
export declare abstract class Joint {
|
|
523
|
+
/** Styling for dev-tools. */
|
|
524
|
+
style: Style;
|
|
525
|
+
/** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */
|
|
526
|
+
appData: Record<string, any>;
|
|
527
|
+
constructor(def: JointDef);
|
|
528
|
+
constructor(def: JointOpt, bodyA: Body$1, bodyB: Body$1);
|
|
529
|
+
/**
|
|
530
|
+
* Short-cut function to determine if either body is inactive.
|
|
531
|
+
*/
|
|
532
|
+
isActive(): boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Get the type of the concrete joint.
|
|
535
|
+
*/
|
|
536
|
+
getType(): string;
|
|
537
|
+
/**
|
|
538
|
+
* Get the first body attached to this joint.
|
|
539
|
+
*/
|
|
540
|
+
getBodyA(): Body$1;
|
|
541
|
+
/**
|
|
542
|
+
* Get the second body attached to this joint.
|
|
543
|
+
*/
|
|
544
|
+
getBodyB(): Body$1;
|
|
545
|
+
/**
|
|
546
|
+
* Get the next joint the world joint list.
|
|
547
|
+
*/
|
|
548
|
+
getNext(): Joint;
|
|
549
|
+
getUserData(): unknown;
|
|
550
|
+
setUserData(data: unknown): void;
|
|
551
|
+
/**
|
|
552
|
+
* Get collide connected. Note: modifying the collide connect flag won't work
|
|
553
|
+
* correctly because the flag is only checked when fixture AABBs begin to
|
|
554
|
+
* overlap.
|
|
555
|
+
*/
|
|
556
|
+
getCollideConnected(): boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
559
|
+
*/
|
|
560
|
+
abstract getAnchorA(): Vec2Value;
|
|
561
|
+
/**
|
|
562
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
563
|
+
*/
|
|
564
|
+
abstract getAnchorB(): Vec2Value;
|
|
565
|
+
/**
|
|
566
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
567
|
+
*/
|
|
568
|
+
abstract getReactionForce(inv_dt: number): Vec2Value;
|
|
569
|
+
/**
|
|
570
|
+
* Get the reaction torque on bodyB in N*m.
|
|
571
|
+
*/
|
|
572
|
+
abstract getReactionTorque(inv_dt: number): number;
|
|
573
|
+
/**
|
|
574
|
+
* Shift the origin for any points stored in world coordinates.
|
|
575
|
+
*/
|
|
576
|
+
shiftOrigin(newOrigin: Vec2Value): void;
|
|
577
|
+
abstract initVelocityConstraints(step: TimeStep): void;
|
|
578
|
+
abstract solveVelocityConstraints(step: TimeStep): void;
|
|
579
|
+
/**
|
|
580
|
+
* This returns true if the position errors are within tolerance.
|
|
581
|
+
*/
|
|
582
|
+
abstract solvePositionConstraints(step: TimeStep): boolean;
|
|
583
|
+
/**
|
|
584
|
+
* @hidden @experimental
|
|
585
|
+
* Update joint with new props.
|
|
586
|
+
*/
|
|
587
|
+
abstract _reset(def: Partial<JointDef>): void;
|
|
588
|
+
}
|
|
589
|
+
export interface Style {
|
|
590
|
+
stroke?: string;
|
|
591
|
+
fill?: string;
|
|
592
|
+
lineWidth?: number;
|
|
593
|
+
}
|
|
594
|
+
export type ActiveKeys = {
|
|
595
|
+
[key in KEY]?: boolean;
|
|
596
|
+
};
|
|
597
|
+
export type TestbedMountOptions = {
|
|
598
|
+
[key: string]: any;
|
|
599
|
+
};
|
|
600
|
+
export declare class Testbed {
|
|
601
|
+
/**
|
|
602
|
+
* Mounts testbed. Call start with a world to start simulation and rendering.
|
|
603
|
+
*/
|
|
604
|
+
static mount(options?: TestbedMountOptions): TestbedInterface;
|
|
605
|
+
/**
|
|
606
|
+
* Mounts testbed if needed, then starts simulation and rendering.
|
|
607
|
+
*
|
|
608
|
+
* If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.
|
|
609
|
+
*/
|
|
610
|
+
static start(world: World): TestbedInterface;
|
|
611
|
+
}
|
|
612
|
+
export interface TestbedInterface {
|
|
613
|
+
/** World viewbox width. */
|
|
614
|
+
width: number;
|
|
615
|
+
/** World viewbox height. */
|
|
616
|
+
height: number;
|
|
617
|
+
/** World viewbox center vertical offset. */
|
|
618
|
+
x: number;
|
|
619
|
+
/** World viewbox center horizontal offset. */
|
|
620
|
+
y: number;
|
|
621
|
+
/** @hidden */
|
|
622
|
+
scaleY: number;
|
|
623
|
+
/** World simulation step frequency */
|
|
624
|
+
hz: number;
|
|
625
|
+
/** World simulation speed, default is 1 */
|
|
626
|
+
speed: number;
|
|
627
|
+
background: string;
|
|
628
|
+
mouseForce?: number;
|
|
629
|
+
activeKeys: ActiveKeys;
|
|
630
|
+
/** callback, to be implemented by user */
|
|
631
|
+
step?: (dt: number, t: number) => void;
|
|
632
|
+
/** callback, to be implemented by user */
|
|
633
|
+
keydown?: (keyCode: number, label: string) => void;
|
|
634
|
+
/** callback, to be implemented by user */
|
|
635
|
+
keyup?: (keyCode: number, label: string) => void;
|
|
636
|
+
status(name: string, value: any): void;
|
|
637
|
+
status(value: object | string): void;
|
|
638
|
+
info(text: string): void;
|
|
639
|
+
color(r: number, g: number, b: number): string;
|
|
640
|
+
drawPoint(p: Vec2Value, r: any, color: string): void;
|
|
641
|
+
drawCircle(p: Vec2Value, r: number, color: string): void;
|
|
642
|
+
drawEdge(a: Vec2Value, b: Vec2Value, color: string): void;
|
|
643
|
+
drawSegment(a: Vec2Value, b: Vec2Value, color: string): void;
|
|
644
|
+
drawPolygon(points: Array<Vec2Value>, color: string): void;
|
|
645
|
+
drawChain(points: Array<Vec2Value>, color: string): void;
|
|
646
|
+
drawAABB(aabb: AABBValue, color: string): void;
|
|
647
|
+
start(world: World): void;
|
|
648
|
+
findOne(query: string): Body$1 | Joint | Fixture | null;
|
|
649
|
+
findAll(query: string): (Body$1 | Joint | Fixture)[];
|
|
650
|
+
}
|
|
651
|
+
export type TestbedFactoryOptions = string | TestbedMountOptions;
|
|
652
|
+
/** @deprecated */
|
|
653
|
+
export type TestbedCallback = (testbed: TestbedInterface) => World | undefined;
|
|
654
|
+
/** @deprecated */
|
|
655
|
+
export declare function testbed(callback: TestbedCallback): void;
|
|
656
|
+
/** @deprecated */
|
|
657
|
+
export declare function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;
|
|
658
|
+
export type KEY = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "right" | "left" | "up" | "down" | "fire";
|
|
659
|
+
/**
|
|
660
|
+
* A shape is used for collision detection. You can create a shape however you
|
|
661
|
+
* like. Shapes used for simulation in World are created automatically when a
|
|
662
|
+
* Fixture is created. Shapes may encapsulate one or more child shapes.
|
|
663
|
+
*/
|
|
664
|
+
export declare abstract class Shape {
|
|
665
|
+
/** @hidden */ m_type: ShapeType;
|
|
666
|
+
/**
|
|
667
|
+
* @hidden
|
|
668
|
+
* Radius of a shape. For polygonal shapes this must be b2_polygonRadius.
|
|
669
|
+
* There is no support for making rounded polygons.
|
|
670
|
+
*/
|
|
671
|
+
m_radius: number;
|
|
672
|
+
/** Styling for dev-tools. */
|
|
673
|
+
style: Style;
|
|
674
|
+
/** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */
|
|
675
|
+
appData: Record<string, any>;
|
|
676
|
+
/** @hidden */
|
|
677
|
+
abstract _reset(): void;
|
|
678
|
+
static isValid(obj: any): boolean;
|
|
679
|
+
abstract getRadius(): number;
|
|
680
|
+
/**
|
|
681
|
+
* Get the type of this shape. You can use this to down cast to the concrete
|
|
682
|
+
* shape.
|
|
683
|
+
*
|
|
684
|
+
* @return the shape type.
|
|
685
|
+
*/
|
|
686
|
+
abstract getType(): ShapeType;
|
|
687
|
+
/**
|
|
688
|
+
* Get the number of child primitives.
|
|
689
|
+
*/
|
|
690
|
+
abstract getChildCount(): number;
|
|
691
|
+
/**
|
|
692
|
+
* Test a point for containment in this shape. This only works for convex
|
|
693
|
+
* shapes.
|
|
694
|
+
*
|
|
695
|
+
* @param xf The shape world transform.
|
|
696
|
+
* @param p A point in world coordinates.
|
|
697
|
+
*/
|
|
698
|
+
abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;
|
|
699
|
+
/**
|
|
700
|
+
* Cast a ray against a child shape.
|
|
701
|
+
*
|
|
702
|
+
* @param output The ray-cast results.
|
|
703
|
+
* @param input The ray-cast input parameters.
|
|
704
|
+
* @param xf The transform to be applied to the shape.
|
|
705
|
+
* @param childIndex The child shape index
|
|
706
|
+
*/
|
|
707
|
+
abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: TransformValue, childIndex: number): boolean;
|
|
708
|
+
/**
|
|
709
|
+
* Given a transform, compute the associated axis aligned bounding box for a
|
|
710
|
+
* child shape.
|
|
711
|
+
*
|
|
712
|
+
* @param aabb Returns the axis aligned box.
|
|
713
|
+
* @param xf The world transform of the shape.
|
|
714
|
+
* @param childIndex The child shape
|
|
715
|
+
*/
|
|
716
|
+
abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;
|
|
717
|
+
/**
|
|
718
|
+
* Compute the mass properties of this shape using its dimensions and density.
|
|
719
|
+
* The inertia tensor is computed about the local origin.
|
|
720
|
+
*
|
|
721
|
+
* @param massData Returns the mass data for this shape.
|
|
722
|
+
* @param density The density in kilograms per meter squared.
|
|
723
|
+
*/
|
|
724
|
+
abstract computeMass(massData: MassData, density?: number): void;
|
|
725
|
+
abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;
|
|
726
|
+
}
|
|
727
|
+
export type ShapeType = "circle" | "edge" | "polygon" | "chain";
|
|
728
|
+
export type DynamicTreeQueryCallback = (nodeId: number) => boolean;
|
|
729
|
+
/**
|
|
730
|
+
* A node in the dynamic tree. The client does not interact with this directly.
|
|
731
|
+
*/
|
|
732
|
+
export declare class TreeNode<T> {
|
|
733
|
+
id: number;
|
|
734
|
+
/** Enlarged AABB */
|
|
735
|
+
aabb: AABB;
|
|
736
|
+
userData: T;
|
|
737
|
+
parent: TreeNode<T>;
|
|
738
|
+
child1: TreeNode<T>;
|
|
739
|
+
child2: TreeNode<T>;
|
|
740
|
+
/** 0: leaf, -1: free node */
|
|
741
|
+
height: number;
|
|
742
|
+
constructor(id?: number);
|
|
743
|
+
isLeaf(): boolean;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A
|
|
747
|
+
* dynamic tree arranges data in a binary tree to accelerate queries such as
|
|
748
|
+
* volume queries and ray casts. Leafs are proxies with an AABB. In the tree we
|
|
749
|
+
* expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger
|
|
750
|
+
* than the client object. This allows the client object to move by small
|
|
751
|
+
* amounts without triggering a tree update.
|
|
752
|
+
*
|
|
753
|
+
* Nodes are pooled and relocatable, so we use node indices rather than
|
|
754
|
+
* pointers.
|
|
755
|
+
*/
|
|
756
|
+
export declare class DynamicTree<T> {
|
|
757
|
+
m_root: TreeNode<T>;
|
|
758
|
+
m_lastProxyId: number;
|
|
759
|
+
m_nodes: {
|
|
760
|
+
[id: number]: TreeNode<T>;
|
|
761
|
+
};
|
|
762
|
+
constructor();
|
|
763
|
+
/**
|
|
764
|
+
* Get proxy user data.
|
|
765
|
+
*
|
|
766
|
+
* @return the proxy user data or 0 if the id is invalid.
|
|
767
|
+
*/
|
|
768
|
+
getUserData(id: number): T;
|
|
769
|
+
/**
|
|
770
|
+
* Get the fat AABB for a node id.
|
|
771
|
+
*
|
|
772
|
+
* @return the proxy user data or 0 if the id is invalid.
|
|
773
|
+
*/
|
|
774
|
+
getFatAABB(id: number): AABB;
|
|
775
|
+
allocateNode(): TreeNode<T>;
|
|
776
|
+
freeNode(node: TreeNode<T>): void;
|
|
777
|
+
/**
|
|
778
|
+
* Create a proxy in the tree as a leaf node. We return the index of the node
|
|
779
|
+
* instead of a pointer so that we can grow the node pool.
|
|
780
|
+
*
|
|
781
|
+
* Create a proxy. Provide a tight fitting AABB and a userData pointer.
|
|
782
|
+
*/
|
|
783
|
+
createProxy(aabb: AABBValue, userData: T): number;
|
|
784
|
+
/**
|
|
785
|
+
* Destroy a proxy. This asserts if the id is invalid.
|
|
786
|
+
*/
|
|
787
|
+
destroyProxy(id: number): void;
|
|
788
|
+
/**
|
|
789
|
+
* Move a proxy with a swepted AABB. If the proxy has moved outside of its
|
|
790
|
+
* fattened AABB, then the proxy is removed from the tree and re-inserted.
|
|
791
|
+
* Otherwise the function returns immediately.
|
|
792
|
+
*
|
|
793
|
+
* @param d Displacement
|
|
794
|
+
*
|
|
795
|
+
* @return true if the proxy was re-inserted.
|
|
796
|
+
*/
|
|
797
|
+
moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean;
|
|
798
|
+
insertLeaf(leaf: TreeNode<T>): void;
|
|
799
|
+
removeLeaf(leaf: TreeNode<T>): void;
|
|
800
|
+
/**
|
|
801
|
+
* Perform a left or right rotation if node A is imbalanced. Returns the new
|
|
802
|
+
* root index.
|
|
803
|
+
*/
|
|
804
|
+
balance(iA: TreeNode<T>): TreeNode<T>;
|
|
805
|
+
/**
|
|
806
|
+
* Compute the height of the binary tree in O(N) time. Should not be called
|
|
807
|
+
* often.
|
|
808
|
+
*/
|
|
809
|
+
getHeight(): number;
|
|
810
|
+
/**
|
|
811
|
+
* Get the ratio of the sum of the node areas to the root area.
|
|
812
|
+
*/
|
|
813
|
+
getAreaRatio(): number;
|
|
814
|
+
/**
|
|
815
|
+
* Compute the height of a sub-tree.
|
|
816
|
+
*/
|
|
817
|
+
computeHeight(id?: number): number;
|
|
818
|
+
validateStructure(node: TreeNode<T>): void;
|
|
819
|
+
validateMetrics(node: TreeNode<T>): void;
|
|
820
|
+
/**
|
|
821
|
+
* Validate this tree. For testing.
|
|
822
|
+
*/
|
|
823
|
+
validate(): void;
|
|
824
|
+
/**
|
|
825
|
+
* Get the maximum balance of an node in the tree. The balance is the difference
|
|
826
|
+
* in height of the two children of a node.
|
|
827
|
+
*/
|
|
828
|
+
getMaxBalance(): number;
|
|
829
|
+
/**
|
|
830
|
+
* Build an optimal tree. Very expensive. For testing.
|
|
831
|
+
*/
|
|
832
|
+
rebuildBottomUp(): void;
|
|
833
|
+
/**
|
|
834
|
+
* Shift the world origin. Useful for large worlds. The shift formula is:
|
|
835
|
+
* position -= newOrigin
|
|
836
|
+
*
|
|
837
|
+
* @param newOrigin The new origin with respect to the old origin
|
|
838
|
+
*/
|
|
839
|
+
shiftOrigin(newOrigin: Vec2Value): void;
|
|
840
|
+
/**
|
|
841
|
+
* Query an AABB for overlapping proxies. The callback class is called for each
|
|
842
|
+
* proxy that overlaps the supplied AABB.
|
|
843
|
+
*/
|
|
844
|
+
query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void;
|
|
845
|
+
/**
|
|
846
|
+
* Ray-cast against the proxies in the tree. This relies on the callback to
|
|
847
|
+
* perform a exact ray-cast in the case were the proxy contains a shape. The
|
|
848
|
+
* callback also performs the any collision filtering. This has performance
|
|
849
|
+
* roughly equal to k * log(n), where k is the number of collisions and n is the
|
|
850
|
+
* number of proxies in the tree.
|
|
851
|
+
*
|
|
852
|
+
* @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.
|
|
853
|
+
* @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.
|
|
854
|
+
*/
|
|
855
|
+
rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void;
|
|
856
|
+
private inputPool;
|
|
857
|
+
private stackPool;
|
|
858
|
+
private iteratorPool;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* The broad-phase wraps and extends a dynamic-tree to keep track of moved
|
|
862
|
+
* objects and query them on update.
|
|
863
|
+
*/
|
|
864
|
+
export declare class BroadPhase {
|
|
865
|
+
m_tree: DynamicTree<FixtureProxy>;
|
|
866
|
+
m_moveBuffer: number[];
|
|
867
|
+
m_callback: (userDataA: any, userDataB: any) => void;
|
|
868
|
+
m_queryProxyId: number;
|
|
869
|
+
/**
|
|
870
|
+
* Get user data from a proxy. Returns null if the id is invalid.
|
|
871
|
+
*/
|
|
872
|
+
getUserData(proxyId: number): FixtureProxy;
|
|
873
|
+
/**
|
|
874
|
+
* Test overlap of fat AABBs.
|
|
875
|
+
*/
|
|
876
|
+
testOverlap(proxyIdA: number, proxyIdB: number): boolean;
|
|
877
|
+
/**
|
|
878
|
+
* Get the fat AABB for a proxy.
|
|
879
|
+
*/
|
|
880
|
+
getFatAABB(proxyId: number): AABB;
|
|
881
|
+
/**
|
|
882
|
+
* Get the number of proxies.
|
|
883
|
+
*/
|
|
884
|
+
getProxyCount(): number;
|
|
885
|
+
/**
|
|
886
|
+
* Get the height of the embedded tree.
|
|
887
|
+
*/
|
|
888
|
+
getTreeHeight(): number;
|
|
889
|
+
/**
|
|
890
|
+
* Get the balance (integer) of the embedded tree.
|
|
891
|
+
*/
|
|
892
|
+
getTreeBalance(): number;
|
|
893
|
+
/**
|
|
894
|
+
* Get the quality metric of the embedded tree.
|
|
895
|
+
*/
|
|
896
|
+
getTreeQuality(): number;
|
|
897
|
+
/**
|
|
898
|
+
* Query an AABB for overlapping proxies. The callback class is called for each
|
|
899
|
+
* proxy that overlaps the supplied AABB.
|
|
900
|
+
*/
|
|
901
|
+
query: (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback) => void;
|
|
902
|
+
/**
|
|
903
|
+
* Ray-cast against the proxies in the tree. This relies on the callback to
|
|
904
|
+
* perform a exact ray-cast in the case were the proxy contains a shape. The
|
|
905
|
+
* callback also performs the any collision filtering. This has performance
|
|
906
|
+
* roughly equal to k * log(n), where k is the number of collisions and n is the
|
|
907
|
+
* number of proxies in the tree.
|
|
908
|
+
*
|
|
909
|
+
* @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.
|
|
910
|
+
* @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.
|
|
911
|
+
*/
|
|
912
|
+
rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void;
|
|
913
|
+
/**
|
|
914
|
+
* Shift the world origin. Useful for large worlds. The shift formula is:
|
|
915
|
+
* position -= newOrigin
|
|
916
|
+
*
|
|
917
|
+
* @param newOrigin The new origin with respect to the old origin
|
|
918
|
+
*/
|
|
919
|
+
shiftOrigin(newOrigin: Vec2Value): void;
|
|
920
|
+
/**
|
|
921
|
+
* Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs
|
|
922
|
+
* is called.
|
|
923
|
+
*/
|
|
924
|
+
createProxy(aabb: AABBValue, userData: FixtureProxy): number;
|
|
925
|
+
/**
|
|
926
|
+
* Destroy a proxy. It is up to the client to remove any pairs.
|
|
927
|
+
*/
|
|
928
|
+
destroyProxy(proxyId: number): void;
|
|
929
|
+
/**
|
|
930
|
+
* Call moveProxy as many times as you like, then when you are done call
|
|
931
|
+
* UpdatePairs to finalized the proxy pairs (for your time step).
|
|
932
|
+
*/
|
|
933
|
+
moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void;
|
|
934
|
+
/**
|
|
935
|
+
* Call to trigger a re-processing of it's pairs on the next call to
|
|
936
|
+
* UpdatePairs.
|
|
937
|
+
*/
|
|
938
|
+
touchProxy(proxyId: number): void;
|
|
939
|
+
bufferMove(proxyId: number): void;
|
|
940
|
+
unbufferMove(proxyId: number): void;
|
|
941
|
+
/**
|
|
942
|
+
* Update the pairs. This results in pair callbacks. This can only add pairs.
|
|
943
|
+
*/
|
|
944
|
+
updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void;
|
|
945
|
+
queryCallback: (proxyId: number) => boolean;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* A fixture definition is used to create a fixture. This class defines an
|
|
949
|
+
* abstract fixture definition. You can reuse fixture definitions safely.
|
|
950
|
+
*/
|
|
951
|
+
export interface FixtureOpt {
|
|
952
|
+
userData?: unknown;
|
|
953
|
+
/**
|
|
954
|
+
* The friction coefficient, usually in the range [0,1]
|
|
955
|
+
*/
|
|
956
|
+
friction?: number;
|
|
957
|
+
/**
|
|
958
|
+
* The restitution (elasticity) usually in the range [0,1]
|
|
959
|
+
*/
|
|
960
|
+
restitution?: number;
|
|
961
|
+
/**
|
|
962
|
+
* The density, usually in kg/m^2
|
|
963
|
+
*/
|
|
964
|
+
density?: number;
|
|
965
|
+
/**
|
|
966
|
+
* A sensor shape collects contact information but never generates a collision response.
|
|
967
|
+
*/
|
|
968
|
+
isSensor?: boolean;
|
|
969
|
+
/**
|
|
970
|
+
* Zero, positive or negative collision group.
|
|
971
|
+
* Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.
|
|
972
|
+
*/
|
|
973
|
+
filterGroupIndex?: number;
|
|
974
|
+
/**
|
|
975
|
+
* Collision category bit or bits that this fixture belongs to.
|
|
976
|
+
* If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.
|
|
977
|
+
*/
|
|
978
|
+
filterCategoryBits?: number;
|
|
979
|
+
/**
|
|
980
|
+
* Collision category bit or bits that this fixture accept for collision.
|
|
981
|
+
*/
|
|
982
|
+
filterMaskBits?: number;
|
|
983
|
+
/** Styling for dev-tools. */
|
|
984
|
+
style?: Style;
|
|
985
|
+
}
|
|
986
|
+
export interface FixtureDef extends FixtureOpt {
|
|
987
|
+
shape: Shape;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* This proxy is used internally to connect shape children to the broad-phase.
|
|
991
|
+
*/
|
|
992
|
+
export declare class FixtureProxy {
|
|
993
|
+
aabb: AABB;
|
|
994
|
+
fixture: Fixture;
|
|
995
|
+
childIndex: number;
|
|
996
|
+
proxyId: number;
|
|
997
|
+
constructor(fixture: Fixture, childIndex: number);
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* A fixture is used to attach a shape to a body for collision detection. A
|
|
1001
|
+
* fixture inherits its transform from its parent. Fixtures hold additional
|
|
1002
|
+
* non-geometric data such as friction, collision filters, etc.
|
|
1003
|
+
*
|
|
1004
|
+
* To create a new Fixture use {@link Body.createFixture}.
|
|
1005
|
+
*/
|
|
1006
|
+
export declare class Fixture {
|
|
1007
|
+
/** Styling for dev-tools. */
|
|
1008
|
+
style: Style;
|
|
1009
|
+
/** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */
|
|
1010
|
+
appData: Record<string, any>;
|
|
1011
|
+
constructor(body: Body$1, def: FixtureDef);
|
|
1012
|
+
constructor(body: Body$1, shape: Shape, def?: FixtureOpt);
|
|
1013
|
+
constructor(body: Body$1, shape: Shape, density?: number);
|
|
1014
|
+
/** @hidden Re-setup fixture. */
|
|
1015
|
+
_reset(): void;
|
|
1016
|
+
/** @hidden */
|
|
1017
|
+
_serialize(): object;
|
|
1018
|
+
/** @hidden */
|
|
1019
|
+
static _deserialize(data: any, body: any, restore: any): Fixture;
|
|
1020
|
+
/**
|
|
1021
|
+
* Get the type of the child shape. You can use this to down cast to the
|
|
1022
|
+
* concrete shape.
|
|
1023
|
+
*/
|
|
1024
|
+
getType(): ShapeType;
|
|
1025
|
+
/**
|
|
1026
|
+
* Get the child shape. You can modify the child shape, however you should not
|
|
1027
|
+
* change the number of vertices because this will crash some collision caching
|
|
1028
|
+
* mechanisms. Manipulating the shape may lead to non-physical behavior.
|
|
1029
|
+
*/
|
|
1030
|
+
getShape(): Shape;
|
|
1031
|
+
/**
|
|
1032
|
+
* A sensor shape collects contact information but never generates a collision
|
|
1033
|
+
* response.
|
|
1034
|
+
*/
|
|
1035
|
+
isSensor(): boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* Set if this fixture is a sensor.
|
|
1038
|
+
*/
|
|
1039
|
+
setSensor(sensor: boolean): void;
|
|
1040
|
+
/**
|
|
1041
|
+
* Get the user data that was assigned in the fixture definition. Use this to
|
|
1042
|
+
* store your application specific data.
|
|
1043
|
+
*/
|
|
1044
|
+
getUserData(): unknown;
|
|
1045
|
+
/**
|
|
1046
|
+
* Set the user data. Use this to store your application specific data.
|
|
1047
|
+
*/
|
|
1048
|
+
setUserData(data: unknown): void;
|
|
1049
|
+
/**
|
|
1050
|
+
* Get the parent body of this fixture. This is null if the fixture is not
|
|
1051
|
+
* attached.
|
|
1052
|
+
*/
|
|
1053
|
+
getBody(): Body$1;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get the next fixture in the parent body's fixture list.
|
|
1056
|
+
*/
|
|
1057
|
+
getNext(): Fixture | null;
|
|
1058
|
+
/**
|
|
1059
|
+
* Get the density of this fixture.
|
|
1060
|
+
*/
|
|
1061
|
+
getDensity(): number;
|
|
1062
|
+
/**
|
|
1063
|
+
* Set the density of this fixture. This will _not_ automatically adjust the
|
|
1064
|
+
* mass of the body. You must call Body.resetMassData to update the body's mass.
|
|
1065
|
+
*/
|
|
1066
|
+
setDensity(density: number): void;
|
|
1067
|
+
/**
|
|
1068
|
+
* Get the coefficient of friction, usually in the range [0,1].
|
|
1069
|
+
*/
|
|
1070
|
+
getFriction(): number;
|
|
1071
|
+
/**
|
|
1072
|
+
* Set the coefficient of friction. This will not change the friction of
|
|
1073
|
+
* existing contacts.
|
|
1074
|
+
*/
|
|
1075
|
+
setFriction(friction: number): void;
|
|
1076
|
+
/**
|
|
1077
|
+
* Get the coefficient of restitution.
|
|
1078
|
+
*/
|
|
1079
|
+
getRestitution(): number;
|
|
1080
|
+
/**
|
|
1081
|
+
* Set the coefficient of restitution. This will not change the restitution of
|
|
1082
|
+
* existing contacts.
|
|
1083
|
+
*/
|
|
1084
|
+
setRestitution(restitution: number): void;
|
|
1085
|
+
/**
|
|
1086
|
+
* Test a point in world coordinates for containment in this fixture.
|
|
1087
|
+
*/
|
|
1088
|
+
testPoint(p: Vec2Value): boolean;
|
|
1089
|
+
/**
|
|
1090
|
+
* Cast a ray against this shape.
|
|
1091
|
+
*/
|
|
1092
|
+
rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean;
|
|
1093
|
+
/**
|
|
1094
|
+
* Get the mass data for this fixture. The mass data is based on the density and
|
|
1095
|
+
* the shape. The rotational inertia is about the shape's origin. This operation
|
|
1096
|
+
* may be expensive.
|
|
1097
|
+
*/
|
|
1098
|
+
getMassData(massData: MassData): void;
|
|
1099
|
+
/**
|
|
1100
|
+
* Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a
|
|
1101
|
+
* more accurate AABB, compute it using the shape and the body transform.
|
|
1102
|
+
*/
|
|
1103
|
+
getAABB(childIndex: number): AABB;
|
|
1104
|
+
/**
|
|
1105
|
+
* These support body activation/deactivation.
|
|
1106
|
+
*/
|
|
1107
|
+
createProxies(broadPhase: BroadPhase, xf: TransformValue): void;
|
|
1108
|
+
destroyProxies(broadPhase: BroadPhase): void;
|
|
1109
|
+
/**
|
|
1110
|
+
* Updates this fixture proxy in broad-phase (with combined AABB of current and
|
|
1111
|
+
* next transformation).
|
|
1112
|
+
*/
|
|
1113
|
+
synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void;
|
|
1114
|
+
/**
|
|
1115
|
+
* Set the contact filtering data. This will not update contacts until the next
|
|
1116
|
+
* time step when either parent body is active and awake. This automatically
|
|
1117
|
+
* calls refilter.
|
|
1118
|
+
*/
|
|
1119
|
+
setFilterData(filter: {
|
|
1120
|
+
groupIndex: number;
|
|
1121
|
+
categoryBits: number;
|
|
1122
|
+
maskBits: number;
|
|
1123
|
+
}): void;
|
|
1124
|
+
getFilterGroupIndex(): number;
|
|
1125
|
+
setFilterGroupIndex(groupIndex: number): void;
|
|
1126
|
+
getFilterCategoryBits(): number;
|
|
1127
|
+
setFilterCategoryBits(categoryBits: number): void;
|
|
1128
|
+
getFilterMaskBits(): number;
|
|
1129
|
+
setFilterMaskBits(maskBits: number): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Call this if you want to establish collision that was previously disabled by
|
|
1132
|
+
* ContactFilter.
|
|
1133
|
+
*/
|
|
1134
|
+
refilter(): void;
|
|
1135
|
+
/**
|
|
1136
|
+
* Implement this method to provide collision filtering, if you want finer
|
|
1137
|
+
* control over contact creation.
|
|
1138
|
+
*
|
|
1139
|
+
* Return true if contact calculations should be performed between these two
|
|
1140
|
+
* fixtures.
|
|
1141
|
+
*
|
|
1142
|
+
* Warning: for performance reasons this is only called when the AABBs begin to
|
|
1143
|
+
* overlap.
|
|
1144
|
+
*/
|
|
1145
|
+
shouldCollide(that: Fixture): boolean;
|
|
1146
|
+
}
|
|
1147
|
+
export declare enum ManifoldType {
|
|
1148
|
+
e_unset = -1,
|
|
1149
|
+
e_circles = 0,
|
|
1150
|
+
e_faceA = 1,
|
|
1151
|
+
e_faceB = 2
|
|
1152
|
+
}
|
|
1153
|
+
export declare enum ContactFeatureType {
|
|
1154
|
+
e_unset = -1,
|
|
1155
|
+
e_vertex = 0,
|
|
1156
|
+
e_face = 1
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* This is used for determining the state of contact points.
|
|
1160
|
+
*/
|
|
1161
|
+
export declare enum PointState {
|
|
1162
|
+
/** Point does not exist */
|
|
1163
|
+
nullState = 0,
|
|
1164
|
+
/** Point was added in the update */
|
|
1165
|
+
addState = 1,
|
|
1166
|
+
/** Point persisted across the update */
|
|
1167
|
+
persistState = 2,
|
|
1168
|
+
/** Point was removed in the update */
|
|
1169
|
+
removeState = 3
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Used for computing contact manifolds.
|
|
1173
|
+
*/
|
|
1174
|
+
export declare class ClipVertex {
|
|
1175
|
+
v: Vec2Value;
|
|
1176
|
+
id: ContactID;
|
|
1177
|
+
set(o: ClipVertex): void;
|
|
1178
|
+
recycle(): void;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* A manifold for two touching convex shapes. Manifolds are created in `evaluate`
|
|
1182
|
+
* method of Contact subclasses.
|
|
1183
|
+
*
|
|
1184
|
+
* Supported manifold types are e_faceA or e_faceB for clip point versus plane
|
|
1185
|
+
* with radius and e_circles point versus point with radius.
|
|
1186
|
+
*
|
|
1187
|
+
* We store contacts in this way so that position correction can account for
|
|
1188
|
+
* movement, which is critical for continuous physics. All contact scenarios
|
|
1189
|
+
* must be expressed in one of these types. This structure is stored across time
|
|
1190
|
+
* steps, so we keep it small.
|
|
1191
|
+
*/
|
|
1192
|
+
export declare class Manifold {
|
|
1193
|
+
type: ManifoldType;
|
|
1194
|
+
/**
|
|
1195
|
+
* Usage depends on manifold type:
|
|
1196
|
+
* - circles: not used
|
|
1197
|
+
* - faceA: the normal on polygonA
|
|
1198
|
+
* - faceB: the normal on polygonB
|
|
1199
|
+
*/
|
|
1200
|
+
localNormal: Vec2Value;
|
|
1201
|
+
/**
|
|
1202
|
+
* Usage depends on manifold type:
|
|
1203
|
+
* - circles: the local center of circleA
|
|
1204
|
+
* - faceA: the center of faceA
|
|
1205
|
+
* - faceB: the center of faceB
|
|
1206
|
+
*/
|
|
1207
|
+
localPoint: Vec2Value;
|
|
1208
|
+
/** The points of contact */
|
|
1209
|
+
points: ManifoldPoint[];
|
|
1210
|
+
/** The number of manifold points */
|
|
1211
|
+
pointCount: number;
|
|
1212
|
+
set(that: Manifold): void;
|
|
1213
|
+
recycle(): void;
|
|
1214
|
+
/**
|
|
1215
|
+
* Evaluate the manifold with supplied transforms. This assumes modest motion
|
|
1216
|
+
* from the original state. This does not change the point count, impulses, etc.
|
|
1217
|
+
* The radii must come from the shapes that generated the manifold.
|
|
1218
|
+
*/
|
|
1219
|
+
getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold;
|
|
1220
|
+
static clipSegmentToLine: typeof clipSegmentToLine;
|
|
1221
|
+
static ClipVertex: typeof ClipVertex;
|
|
1222
|
+
static getPointStates: typeof getPointStates;
|
|
1223
|
+
static PointState: typeof PointState;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* A manifold point is a contact point belonging to a contact manifold. It holds
|
|
1227
|
+
* details related to the geometry and dynamics of the contact points.
|
|
1228
|
+
*
|
|
1229
|
+
* This structure is stored across time steps, so we keep it small.
|
|
1230
|
+
*
|
|
1231
|
+
* Note: impulses are used for internal caching and may not provide reliable
|
|
1232
|
+
* contact forces, especially for high speed collisions.
|
|
1233
|
+
*/
|
|
1234
|
+
export declare class ManifoldPoint {
|
|
1235
|
+
/**
|
|
1236
|
+
* Usage depends on manifold type:
|
|
1237
|
+
* - circles: the local center of circleB
|
|
1238
|
+
* - faceA: the local center of circleB or the clip point of polygonB
|
|
1239
|
+
* - faceB: the clip point of polygonA
|
|
1240
|
+
*/
|
|
1241
|
+
localPoint: Vec2Value;
|
|
1242
|
+
/**
|
|
1243
|
+
* The non-penetration impulse
|
|
1244
|
+
*/
|
|
1245
|
+
normalImpulse: number;
|
|
1246
|
+
/**
|
|
1247
|
+
* The friction impulse
|
|
1248
|
+
*/
|
|
1249
|
+
tangentImpulse: number;
|
|
1250
|
+
/**
|
|
1251
|
+
* Uniquely identifies a contact point between two shapes to facilitate warm starting
|
|
1252
|
+
*/
|
|
1253
|
+
readonly id: ContactID;
|
|
1254
|
+
set(that: ManifoldPoint): void;
|
|
1255
|
+
recycle(): void;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Contact ids to facilitate warm starting.
|
|
1259
|
+
*
|
|
1260
|
+
* ContactFeature: The features that intersect to form the contact point.
|
|
1261
|
+
*/
|
|
1262
|
+
export declare class ContactID {
|
|
1263
|
+
/**
|
|
1264
|
+
* Used to quickly compare contact ids.
|
|
1265
|
+
*/
|
|
1266
|
+
key: number;
|
|
1267
|
+
/** ContactFeature index on shapeA */
|
|
1268
|
+
indexA: number;
|
|
1269
|
+
/** ContactFeature index on shapeB */
|
|
1270
|
+
indexB: number;
|
|
1271
|
+
/** ContactFeature type on shapeA */
|
|
1272
|
+
typeA: ContactFeatureType;
|
|
1273
|
+
/** ContactFeature type on shapeB */
|
|
1274
|
+
typeB: ContactFeatureType;
|
|
1275
|
+
setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void;
|
|
1276
|
+
set(that: ContactID): void;
|
|
1277
|
+
swapFeatures(): void;
|
|
1278
|
+
recycle(): void;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* This is used to compute the current state of a contact manifold.
|
|
1282
|
+
*/
|
|
1283
|
+
export declare class WorldManifold {
|
|
1284
|
+
/** World vector pointing from A to B */
|
|
1285
|
+
normal: Vec2Value;
|
|
1286
|
+
/** World contact point (point of intersection) */
|
|
1287
|
+
points: Vec2Value[];
|
|
1288
|
+
/** A negative value indicates overlap, in meters */
|
|
1289
|
+
separations: number[];
|
|
1290
|
+
/** The number of manifold points */
|
|
1291
|
+
pointCount: number;
|
|
1292
|
+
recycle(): void;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Compute the point states given two manifolds. The states pertain to the
|
|
1296
|
+
* transition from manifold1 to manifold2. So state1 is either persist or remove
|
|
1297
|
+
* while state2 is either add or persist.
|
|
1298
|
+
*/
|
|
1299
|
+
export declare function getPointStates(state1: PointState[], state2: PointState[], manifold1: Manifold, manifold2: Manifold): void;
|
|
1300
|
+
/**
|
|
1301
|
+
* Clipping for contact manifolds. Sutherland-Hodgman clipping.
|
|
1302
|
+
*/
|
|
1303
|
+
export declare function clipSegmentToLine(vOut: ClipVertex[], vIn: ClipVertex[], normal: Vec2Value, offset: number, vertexIndexA: number): number;
|
|
1304
|
+
/**
|
|
1305
|
+
* A contact edge is used to connect bodies and contacts together in a contact
|
|
1306
|
+
* graph where each body is a node and each contact is an edge. A contact edge
|
|
1307
|
+
* belongs to a doubly linked list maintained in each attached body. Each
|
|
1308
|
+
* contact has two contact nodes, one for each attached body.
|
|
1309
|
+
*/
|
|
1310
|
+
export declare class ContactEdge {
|
|
1311
|
+
contact: Contact;
|
|
1312
|
+
prev: ContactEdge | null;
|
|
1313
|
+
next: ContactEdge | null;
|
|
1314
|
+
other: Body$1 | null;
|
|
1315
|
+
constructor(contact: Contact);
|
|
1316
|
+
}
|
|
1317
|
+
export type EvaluateFunction = (manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number) => void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Friction mixing law. The idea is to allow either fixture to drive the
|
|
1320
|
+
* friction to zero. For example, anything slides on ice.
|
|
1321
|
+
*/
|
|
1322
|
+
export declare function mixFriction(friction1: number, friction2: number): number;
|
|
1323
|
+
/**
|
|
1324
|
+
* Restitution mixing law. The idea is allow for anything to bounce off an
|
|
1325
|
+
* inelastic surface. For example, a superball bounces on anything.
|
|
1326
|
+
*/
|
|
1327
|
+
export declare function mixRestitution(restitution1: number, restitution2: number): number;
|
|
1328
|
+
export declare class VelocityConstraintPoint {
|
|
1329
|
+
rA: Vec2Value;
|
|
1330
|
+
rB: Vec2Value;
|
|
1331
|
+
normalImpulse: number;
|
|
1332
|
+
tangentImpulse: number;
|
|
1333
|
+
normalMass: number;
|
|
1334
|
+
tangentMass: number;
|
|
1335
|
+
velocityBias: number;
|
|
1336
|
+
recycle(): void;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* The class manages contact between two shapes. A contact exists for each
|
|
1340
|
+
* overlapping AABB in the broad-phase (except if filtered). Therefore a contact
|
|
1341
|
+
* object may exist that has no contact points.
|
|
1342
|
+
*/
|
|
1343
|
+
export declare class Contact {
|
|
1344
|
+
initConstraint(step: TimeStep): void;
|
|
1345
|
+
/**
|
|
1346
|
+
* Get the contact manifold. Do not modify the manifold unless you understand
|
|
1347
|
+
* the internals of the library.
|
|
1348
|
+
*/
|
|
1349
|
+
getManifold(): Manifold;
|
|
1350
|
+
/**
|
|
1351
|
+
* Get the world manifold.
|
|
1352
|
+
*/
|
|
1353
|
+
getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined;
|
|
1354
|
+
/**
|
|
1355
|
+
* Enable/disable this contact. This can be used inside the pre-solve contact
|
|
1356
|
+
* listener. The contact is only disabled for the current time step (or sub-step
|
|
1357
|
+
* in continuous collisions).
|
|
1358
|
+
*/
|
|
1359
|
+
setEnabled(flag: boolean): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* Has this contact been disabled?
|
|
1362
|
+
*/
|
|
1363
|
+
isEnabled(): boolean;
|
|
1364
|
+
/**
|
|
1365
|
+
* Is this contact touching?
|
|
1366
|
+
*/
|
|
1367
|
+
isTouching(): boolean;
|
|
1368
|
+
/**
|
|
1369
|
+
* Get the next contact in the world's contact list.
|
|
1370
|
+
*/
|
|
1371
|
+
getNext(): Contact | null;
|
|
1372
|
+
/**
|
|
1373
|
+
* Get fixture A in this contact.
|
|
1374
|
+
*/
|
|
1375
|
+
getFixtureA(): Fixture;
|
|
1376
|
+
/**
|
|
1377
|
+
* Get fixture B in this contact.
|
|
1378
|
+
*/
|
|
1379
|
+
getFixtureB(): Fixture;
|
|
1380
|
+
/**
|
|
1381
|
+
* Get the child primitive index for fixture A.
|
|
1382
|
+
*/
|
|
1383
|
+
getChildIndexA(): number;
|
|
1384
|
+
/**
|
|
1385
|
+
* Get the child primitive index for fixture B.
|
|
1386
|
+
*/
|
|
1387
|
+
getChildIndexB(): number;
|
|
1388
|
+
/**
|
|
1389
|
+
* Flag this contact for filtering. Filtering will occur the next time step.
|
|
1390
|
+
*/
|
|
1391
|
+
flagForFiltering(): void;
|
|
1392
|
+
/**
|
|
1393
|
+
* Override the default friction mixture. You can call this in
|
|
1394
|
+
* "pre-solve" callback. This value persists until set or reset.
|
|
1395
|
+
*/
|
|
1396
|
+
setFriction(friction: number): void;
|
|
1397
|
+
/**
|
|
1398
|
+
* Get the friction.
|
|
1399
|
+
*/
|
|
1400
|
+
getFriction(): number;
|
|
1401
|
+
/**
|
|
1402
|
+
* Reset the friction mixture to the default value.
|
|
1403
|
+
*/
|
|
1404
|
+
resetFriction(): void;
|
|
1405
|
+
/**
|
|
1406
|
+
* Override the default restitution mixture. You can call this in
|
|
1407
|
+
* "pre-solve" callback. The value persists until you set or reset.
|
|
1408
|
+
*/
|
|
1409
|
+
setRestitution(restitution: number): void;
|
|
1410
|
+
/**
|
|
1411
|
+
* Get the restitution.
|
|
1412
|
+
*/
|
|
1413
|
+
getRestitution(): number;
|
|
1414
|
+
/**
|
|
1415
|
+
* Reset the restitution to the default value.
|
|
1416
|
+
*/
|
|
1417
|
+
resetRestitution(): void;
|
|
1418
|
+
/**
|
|
1419
|
+
* Set the desired tangent speed for a conveyor belt behavior. In meters per
|
|
1420
|
+
* second.
|
|
1421
|
+
*/
|
|
1422
|
+
setTangentSpeed(speed: number): void;
|
|
1423
|
+
/**
|
|
1424
|
+
* Get the desired tangent speed. In meters per second.
|
|
1425
|
+
*/
|
|
1426
|
+
getTangentSpeed(): number;
|
|
1427
|
+
/**
|
|
1428
|
+
* Called by Update method, and implemented by subclasses.
|
|
1429
|
+
*/
|
|
1430
|
+
evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void;
|
|
1431
|
+
/**
|
|
1432
|
+
* Updates the contact manifold and touching status.
|
|
1433
|
+
*
|
|
1434
|
+
* Note: do not assume the fixture AABBs are overlapping or are valid.
|
|
1435
|
+
*
|
|
1436
|
+
* @param listener.beginContact
|
|
1437
|
+
* @param listener.endContact
|
|
1438
|
+
* @param listener.preSolve
|
|
1439
|
+
*/
|
|
1440
|
+
update(listener?: {
|
|
1441
|
+
beginContact(contact: Contact): void;
|
|
1442
|
+
endContact(contact: Contact): void;
|
|
1443
|
+
preSolve(contact: Contact, oldManifold: Manifold): void;
|
|
1444
|
+
}): void;
|
|
1445
|
+
solvePositionConstraint(step: TimeStep): number;
|
|
1446
|
+
solvePositionConstraintTOI(step: TimeStep, toiA: Body$1, toiB: Body$1): number;
|
|
1447
|
+
private _solvePositionConstraint;
|
|
1448
|
+
initVelocityConstraint(step: TimeStep): void;
|
|
1449
|
+
warmStartConstraint(step: TimeStep): void;
|
|
1450
|
+
storeConstraintImpulses(step: TimeStep): void;
|
|
1451
|
+
solveVelocityConstraint(step: TimeStep): void;
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* A static body does not move under simulation and behaves as if it has infinite mass.
|
|
1455
|
+
* Internally, zero is stored for the mass and the inverse mass.
|
|
1456
|
+
* Static bodies can be moved manually by the user.
|
|
1457
|
+
* A static body has zero velocity.
|
|
1458
|
+
* Static bodies do not collide with other static or kinematic bodies.
|
|
1459
|
+
*
|
|
1460
|
+
* A kinematic body moves under simulation according to its velocity.
|
|
1461
|
+
* Kinematic bodies do not respond to forces.
|
|
1462
|
+
* They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.
|
|
1463
|
+
* A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.
|
|
1464
|
+
* Kinematic bodies do not collide with other kinematic or static bodies.
|
|
1465
|
+
*
|
|
1466
|
+
* A dynamic body is fully simulated.
|
|
1467
|
+
* They can be moved manually by the user, but normally they move according to forces.
|
|
1468
|
+
* A dynamic body can collide with all body types.
|
|
1469
|
+
* A dynamic body always has finite, non-zero mass.
|
|
1470
|
+
* If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.
|
|
1471
|
+
*/
|
|
1472
|
+
export type BodyType = "static" | "kinematic" | "dynamic";
|
|
1473
|
+
export interface BodyDef {
|
|
1474
|
+
/**
|
|
1475
|
+
* Body types are static, kinematic, or dynamic. Note: if a dynamic
|
|
1476
|
+
* body would have zero mass, the mass is set to one.
|
|
1477
|
+
*/
|
|
1478
|
+
type?: BodyType;
|
|
1479
|
+
/**
|
|
1480
|
+
* The world position of the body. Avoid creating bodies at the
|
|
1481
|
+
* origin since this can lead to many overlapping shapes.
|
|
1482
|
+
*/
|
|
1483
|
+
position?: Vec2Value;
|
|
1484
|
+
/**
|
|
1485
|
+
* The world angle of the body in radians.
|
|
1486
|
+
*/
|
|
1487
|
+
angle?: number;
|
|
1488
|
+
/**
|
|
1489
|
+
* The linear velocity of the body's origin in world co-ordinates.
|
|
1490
|
+
*/
|
|
1491
|
+
linearVelocity?: Vec2Value;
|
|
1492
|
+
angularVelocity?: number;
|
|
1493
|
+
/**
|
|
1494
|
+
* Linear damping is use to reduce the linear velocity. The
|
|
1495
|
+
* damping parameter can be larger than 1.0 but the damping effect becomes
|
|
1496
|
+
* sensitive to the time step when the damping parameter is large.
|
|
1497
|
+
* Units are 1/time
|
|
1498
|
+
*/
|
|
1499
|
+
linearDamping?: number;
|
|
1500
|
+
/**
|
|
1501
|
+
* Angular damping is use to reduce the angular velocity.
|
|
1502
|
+
* The damping parameter can be larger than 1.0 but the damping effect
|
|
1503
|
+
* becomes sensitive to the time step when the damping parameter is large.
|
|
1504
|
+
* Units are 1/time
|
|
1505
|
+
*/
|
|
1506
|
+
angularDamping?: number;
|
|
1507
|
+
/**
|
|
1508
|
+
* Should this body be prevented from rotating? Useful for characters.
|
|
1509
|
+
*/
|
|
1510
|
+
fixedRotation?: boolean;
|
|
1511
|
+
/**
|
|
1512
|
+
* Is this a fast moving body that should be prevented from
|
|
1513
|
+
* tunneling through other moving bodies? Note that all bodies are
|
|
1514
|
+
* prevented from tunneling through kinematic and static bodies. This
|
|
1515
|
+
* setting is only considered on dynamic bodies. Warning: You should use
|
|
1516
|
+
* this flag sparingly since it increases processing time.
|
|
1517
|
+
*/
|
|
1518
|
+
bullet?: boolean;
|
|
1519
|
+
gravityScale?: number;
|
|
1520
|
+
/**
|
|
1521
|
+
* Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.
|
|
1522
|
+
*/
|
|
1523
|
+
allowSleep?: boolean;
|
|
1524
|
+
/**
|
|
1525
|
+
* Is this body initially awake or sleeping?
|
|
1526
|
+
*/
|
|
1527
|
+
awake?: boolean;
|
|
1528
|
+
/**
|
|
1529
|
+
* Does this body start out active?
|
|
1530
|
+
*/
|
|
1531
|
+
active?: boolean;
|
|
1532
|
+
userData?: any;
|
|
1533
|
+
/** Styling for dev-tools. */
|
|
1534
|
+
style?: Style;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* MassData This holds the mass data computed for a shape.
|
|
1538
|
+
*/
|
|
1539
|
+
export interface MassData {
|
|
1540
|
+
/** The mass of the shape, usually in kilograms. */
|
|
1541
|
+
mass: number;
|
|
1542
|
+
/** The position of the shape's centroid relative to the shape's origin. */
|
|
1543
|
+
center: Vec2Value;
|
|
1544
|
+
/** The rotational inertia of the shape about the local origin. */
|
|
1545
|
+
I: number;
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* A rigid body composed of one or more fixtures.
|
|
1549
|
+
*
|
|
1550
|
+
* To create a new Body use {@link World.createBody}.
|
|
1551
|
+
*/
|
|
1552
|
+
declare class Body$1 {
|
|
1553
|
+
/** @hidden */
|
|
1554
|
+
static readonly STATIC: BodyType;
|
|
1555
|
+
/** @hidden */
|
|
1556
|
+
static readonly KINEMATIC: BodyType;
|
|
1557
|
+
/** @hidden */
|
|
1558
|
+
static readonly DYNAMIC: BodyType;
|
|
1559
|
+
/** Styling for dev-tools. */
|
|
1560
|
+
style: Style;
|
|
1561
|
+
/** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */
|
|
1562
|
+
appData: Record<string, any>;
|
|
1563
|
+
/** @hidden */
|
|
1564
|
+
_serialize(): object;
|
|
1565
|
+
/** @hidden */
|
|
1566
|
+
static _deserialize(data: any, world: any, restore: any): Body$1;
|
|
1567
|
+
isWorldLocked(): boolean;
|
|
1568
|
+
getWorld(): World;
|
|
1569
|
+
getNext(): Body$1 | null;
|
|
1570
|
+
setUserData(data: any): void;
|
|
1571
|
+
getUserData(): unknown;
|
|
1572
|
+
getFixtureList(): Fixture | null;
|
|
1573
|
+
getJointList(): JointEdge | null;
|
|
1574
|
+
/**
|
|
1575
|
+
* Warning: this list changes during the time step and you may miss some
|
|
1576
|
+
* collisions if you don't use ContactListener.
|
|
1577
|
+
*/
|
|
1578
|
+
getContactList(): ContactEdge | null;
|
|
1579
|
+
isStatic(): boolean;
|
|
1580
|
+
isDynamic(): boolean;
|
|
1581
|
+
isKinematic(): boolean;
|
|
1582
|
+
/**
|
|
1583
|
+
* This will alter the mass and velocity.
|
|
1584
|
+
*/
|
|
1585
|
+
setStatic(): Body$1;
|
|
1586
|
+
setDynamic(): Body$1;
|
|
1587
|
+
setKinematic(): Body$1;
|
|
1588
|
+
/**
|
|
1589
|
+
* Get the type of the body.
|
|
1590
|
+
*/
|
|
1591
|
+
getType(): BodyType;
|
|
1592
|
+
/**
|
|
1593
|
+
* Set the type of the body to "static", "kinematic" or "dynamic".
|
|
1594
|
+
* @param type The type of the body.
|
|
1595
|
+
*
|
|
1596
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1597
|
+
*/
|
|
1598
|
+
setType(type: BodyType): void;
|
|
1599
|
+
isBullet(): boolean;
|
|
1600
|
+
/**
|
|
1601
|
+
* Should this body be treated like a bullet for continuous collision detection?
|
|
1602
|
+
*/
|
|
1603
|
+
setBullet(flag: boolean): void;
|
|
1604
|
+
isSleepingAllowed(): boolean;
|
|
1605
|
+
setSleepingAllowed(flag: boolean): void;
|
|
1606
|
+
isAwake(): boolean;
|
|
1607
|
+
/**
|
|
1608
|
+
* Set the sleep state of the body. A sleeping body has very low CPU cost.
|
|
1609
|
+
*
|
|
1610
|
+
* @param flag Set to true to wake the body, false to put it to sleep.
|
|
1611
|
+
*/
|
|
1612
|
+
setAwake(flag: boolean): void;
|
|
1613
|
+
isActive(): boolean;
|
|
1614
|
+
/**
|
|
1615
|
+
* Set the active state of the body. An inactive body is not simulated and
|
|
1616
|
+
* cannot be collided with or woken up. If you pass a flag of true, all fixtures
|
|
1617
|
+
* will be added to the broad-phase. If you pass a flag of false, all fixtures
|
|
1618
|
+
* will be removed from the broad-phase and all contacts will be destroyed.
|
|
1619
|
+
* Fixtures and joints are otherwise unaffected.
|
|
1620
|
+
*
|
|
1621
|
+
* You may continue to create/destroy fixtures and joints on inactive bodies.
|
|
1622
|
+
* Fixtures on an inactive body are implicitly inactive and will not participate
|
|
1623
|
+
* in collisions, ray-casts, or queries. Joints connected to an inactive body
|
|
1624
|
+
* are implicitly inactive. An inactive body is still owned by a World object
|
|
1625
|
+
* and remains
|
|
1626
|
+
*
|
|
1627
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1628
|
+
*/
|
|
1629
|
+
setActive(flag: boolean): void;
|
|
1630
|
+
isFixedRotation(): boolean;
|
|
1631
|
+
/**
|
|
1632
|
+
* Set this body to have fixed rotation. This causes the mass to be reset.
|
|
1633
|
+
*/
|
|
1634
|
+
setFixedRotation(flag: boolean): void;
|
|
1635
|
+
/**
|
|
1636
|
+
* Get the world transform for the body's origin.
|
|
1637
|
+
*/
|
|
1638
|
+
getTransform(): TransformValue;
|
|
1639
|
+
/**
|
|
1640
|
+
* Set the position of the body's origin and rotation. Manipulating a body's
|
|
1641
|
+
* transform may cause non-physical behavior. Note: contacts are updated on the
|
|
1642
|
+
* next call to World.step.
|
|
1643
|
+
*
|
|
1644
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1645
|
+
*
|
|
1646
|
+
* @param position The world position of the body's local origin.
|
|
1647
|
+
* @param angle The world rotation in radians.
|
|
1648
|
+
*/
|
|
1649
|
+
setTransform(position: Vec2Value, angle: number): void;
|
|
1650
|
+
/**
|
|
1651
|
+
* Set the position of the body's origin and rotation. Manipulating a body's
|
|
1652
|
+
* transform may cause non-physical behavior. Note: contacts are updated on the
|
|
1653
|
+
* next call to World.step.
|
|
1654
|
+
*
|
|
1655
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1656
|
+
*/
|
|
1657
|
+
setTransform(xf: TransformValue): void;
|
|
1658
|
+
synchronizeTransform(): void;
|
|
1659
|
+
/**
|
|
1660
|
+
* Update fixtures in broad-phase.
|
|
1661
|
+
*/
|
|
1662
|
+
synchronizeFixtures(): void;
|
|
1663
|
+
/**
|
|
1664
|
+
* Used in TOI.
|
|
1665
|
+
*/
|
|
1666
|
+
advance(alpha: number): void;
|
|
1667
|
+
/**
|
|
1668
|
+
* Get the world position for the body's origin.
|
|
1669
|
+
*/
|
|
1670
|
+
getPosition(): Vec2Value;
|
|
1671
|
+
setPosition(p: Vec2Value): void;
|
|
1672
|
+
/**
|
|
1673
|
+
* Get the current world rotation angle in radians.
|
|
1674
|
+
*/
|
|
1675
|
+
getAngle(): number;
|
|
1676
|
+
setAngle(angle: number): void;
|
|
1677
|
+
/**
|
|
1678
|
+
* Get the world position of the center of mass.
|
|
1679
|
+
*/
|
|
1680
|
+
getWorldCenter(): Vec2Value;
|
|
1681
|
+
/**
|
|
1682
|
+
* Get the local position of the center of mass.
|
|
1683
|
+
*/
|
|
1684
|
+
getLocalCenter(): Vec2Value;
|
|
1685
|
+
/**
|
|
1686
|
+
* Get the linear velocity of the center of mass.
|
|
1687
|
+
*
|
|
1688
|
+
* @return the linear velocity of the center of mass.
|
|
1689
|
+
*/
|
|
1690
|
+
getLinearVelocity(): Vec2Value;
|
|
1691
|
+
/**
|
|
1692
|
+
* Get the world linear velocity of a world point attached to this body.
|
|
1693
|
+
*
|
|
1694
|
+
* @param worldPoint A point in world coordinates.
|
|
1695
|
+
*/
|
|
1696
|
+
getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2Value;
|
|
1697
|
+
/**
|
|
1698
|
+
* Get the world velocity of a local point.
|
|
1699
|
+
*
|
|
1700
|
+
* @param localPoint A point in local coordinates.
|
|
1701
|
+
*/
|
|
1702
|
+
getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2Value;
|
|
1703
|
+
/**
|
|
1704
|
+
* Set the linear velocity of the center of mass.
|
|
1705
|
+
*
|
|
1706
|
+
* @param v The new linear velocity of the center of mass.
|
|
1707
|
+
*/
|
|
1708
|
+
setLinearVelocity(v: Vec2Value): void;
|
|
1709
|
+
/**
|
|
1710
|
+
* Get the angular velocity.
|
|
1711
|
+
*
|
|
1712
|
+
* @returns the angular velocity in radians/second.
|
|
1713
|
+
*/
|
|
1714
|
+
getAngularVelocity(): number;
|
|
1715
|
+
/**
|
|
1716
|
+
* Set the angular velocity.
|
|
1717
|
+
*
|
|
1718
|
+
* @param w The new angular velocity in radians/second.
|
|
1719
|
+
*/
|
|
1720
|
+
setAngularVelocity(w: number): void;
|
|
1721
|
+
getLinearDamping(): number;
|
|
1722
|
+
setLinearDamping(linearDamping: number): void;
|
|
1723
|
+
getAngularDamping(): number;
|
|
1724
|
+
setAngularDamping(angularDamping: number): void;
|
|
1725
|
+
getGravityScale(): number;
|
|
1726
|
+
/**
|
|
1727
|
+
* Scale the gravity applied to this body.
|
|
1728
|
+
*/
|
|
1729
|
+
setGravityScale(scale: number): void;
|
|
1730
|
+
/**
|
|
1731
|
+
* Get the total mass of the body.
|
|
1732
|
+
*
|
|
1733
|
+
* @returns The mass, usually in kilograms (kg).
|
|
1734
|
+
*/
|
|
1735
|
+
getMass(): number;
|
|
1736
|
+
/**
|
|
1737
|
+
* Get the rotational inertia of the body about the local origin.
|
|
1738
|
+
*
|
|
1739
|
+
* @return the rotational inertia, usually in kg-m^2.
|
|
1740
|
+
*/
|
|
1741
|
+
getInertia(): number;
|
|
1742
|
+
/**
|
|
1743
|
+
* Copy the mass data of the body to data.
|
|
1744
|
+
*/
|
|
1745
|
+
getMassData(data: MassData): void;
|
|
1746
|
+
/**
|
|
1747
|
+
* This resets the mass properties to the sum of the mass properties of the
|
|
1748
|
+
* fixtures. This normally does not need to be called unless you called
|
|
1749
|
+
* SetMassData to override the mass and you later want to reset the mass.
|
|
1750
|
+
*/
|
|
1751
|
+
resetMassData(): void;
|
|
1752
|
+
/**
|
|
1753
|
+
* Set the mass properties to override the mass properties of the fixtures. Note
|
|
1754
|
+
* that this changes the center of mass position. Note that creating or
|
|
1755
|
+
* destroying fixtures can also alter the mass. This function has no effect if
|
|
1756
|
+
* the body isn't dynamic.
|
|
1757
|
+
*
|
|
1758
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1759
|
+
*
|
|
1760
|
+
* @param massData The mass properties.
|
|
1761
|
+
*/
|
|
1762
|
+
setMassData(massData: MassData): void;
|
|
1763
|
+
/**
|
|
1764
|
+
* Apply a force at a world point. If the force is not applied at the center of
|
|
1765
|
+
* mass, it will generate a torque and affect the angular velocity. This wakes
|
|
1766
|
+
* up the body.
|
|
1767
|
+
*
|
|
1768
|
+
* @param force The world force vector, usually in Newtons (N).
|
|
1769
|
+
* @param point The world position of the point of application.
|
|
1770
|
+
* @param wake Also wake up the body
|
|
1771
|
+
*/
|
|
1772
|
+
applyForce(force: Vec2Value, point: Vec2Value, wake?: boolean): void;
|
|
1773
|
+
/**
|
|
1774
|
+
* Apply a force to the center of mass. This wakes up the body.
|
|
1775
|
+
*
|
|
1776
|
+
* @param force The world force vector, usually in Newtons (N).
|
|
1777
|
+
* @param wake Also wake up the body
|
|
1778
|
+
*/
|
|
1779
|
+
applyForceToCenter(force: Vec2Value, wake?: boolean): void;
|
|
1780
|
+
/**
|
|
1781
|
+
* Apply a torque. This affects the angular velocity without affecting the
|
|
1782
|
+
* linear velocity of the center of mass. This wakes up the body.
|
|
1783
|
+
*
|
|
1784
|
+
* @param torque About the z-axis (out of the screen), usually in N-m.
|
|
1785
|
+
* @param wake Also wake up the body
|
|
1786
|
+
*/
|
|
1787
|
+
applyTorque(torque: number, wake?: boolean): void;
|
|
1788
|
+
/**
|
|
1789
|
+
* Apply an impulse at a point. This immediately modifies the velocity. It also
|
|
1790
|
+
* modifies the angular velocity if the point of application is not at the
|
|
1791
|
+
* center of mass. This wakes up the body.
|
|
1792
|
+
*
|
|
1793
|
+
* @param impulse The world impulse vector, usually in N-seconds or kg-m/s.
|
|
1794
|
+
* @param point The world position of the point of application.
|
|
1795
|
+
* @param wake Also wake up the body
|
|
1796
|
+
*/
|
|
1797
|
+
applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake?: boolean): void;
|
|
1798
|
+
/**
|
|
1799
|
+
* Apply an angular impulse.
|
|
1800
|
+
*
|
|
1801
|
+
* @param impulse The angular impulse in units of kg*m*m/s
|
|
1802
|
+
* @param wake Also wake up the body
|
|
1803
|
+
*/
|
|
1804
|
+
applyAngularImpulse(impulse: number, wake?: boolean): void;
|
|
1805
|
+
/**
|
|
1806
|
+
* This is used to test if two bodies should collide.
|
|
1807
|
+
*
|
|
1808
|
+
* Bodies do not collide when:
|
|
1809
|
+
* - Neither of them is dynamic
|
|
1810
|
+
* - They are connected by a joint with collideConnected == false
|
|
1811
|
+
*/
|
|
1812
|
+
shouldCollide(that: Body$1): boolean;
|
|
1813
|
+
/**
|
|
1814
|
+
* Creates a fixture and attach it to this body.
|
|
1815
|
+
*
|
|
1816
|
+
* If the density is non-zero, this function automatically updates the mass of
|
|
1817
|
+
* the body.
|
|
1818
|
+
*
|
|
1819
|
+
* Contacts are not created until the next time step.
|
|
1820
|
+
*
|
|
1821
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1822
|
+
*/
|
|
1823
|
+
createFixture(def: FixtureDef): Fixture;
|
|
1824
|
+
createFixture(shape: Shape, opt?: FixtureOpt): Fixture;
|
|
1825
|
+
createFixture(shape: Shape, density?: number): Fixture;
|
|
1826
|
+
/**
|
|
1827
|
+
* Destroy a fixture. This removes the fixture from the broad-phase and destroys
|
|
1828
|
+
* all contacts associated with this fixture. This will automatically adjust the
|
|
1829
|
+
* mass of the body if the body is dynamic and the fixture has positive density.
|
|
1830
|
+
* All fixtures attached to a body are implicitly destroyed when the body is
|
|
1831
|
+
* destroyed.
|
|
1832
|
+
*
|
|
1833
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
1834
|
+
*
|
|
1835
|
+
* @param fixture The fixture to be removed.
|
|
1836
|
+
*/
|
|
1837
|
+
destroyFixture(fixture: Fixture): void;
|
|
1838
|
+
/**
|
|
1839
|
+
* Get the corresponding world point of a local point.
|
|
1840
|
+
*/
|
|
1841
|
+
getWorldPoint(localPoint: Vec2Value): Vec2Value;
|
|
1842
|
+
/**
|
|
1843
|
+
* Get the corresponding world vector of a local vector.
|
|
1844
|
+
*/
|
|
1845
|
+
getWorldVector(localVector: Vec2Value): Vec2Value;
|
|
1846
|
+
/**
|
|
1847
|
+
* Gets the corresponding local point of a world point.
|
|
1848
|
+
*/
|
|
1849
|
+
getLocalPoint(worldPoint: Vec2Value): Vec2Value;
|
|
1850
|
+
/**
|
|
1851
|
+
* Gets the corresponding local vector of a world vector.
|
|
1852
|
+
*/
|
|
1853
|
+
getLocalVector(worldVector: Vec2Value): Vec2Value;
|
|
1854
|
+
}
|
|
1855
|
+
export declare class TimeStep {
|
|
1856
|
+
/** time step */
|
|
1857
|
+
dt: number;
|
|
1858
|
+
/** inverse time step (0 if dt == 0) */
|
|
1859
|
+
inv_dt: number;
|
|
1860
|
+
velocityIterations: number;
|
|
1861
|
+
positionIterations: number;
|
|
1862
|
+
warmStarting: boolean;
|
|
1863
|
+
blockSolve: boolean;
|
|
1864
|
+
/** timestep ratio for variable timestep */
|
|
1865
|
+
inv_dt0: number;
|
|
1866
|
+
/** dt * inv_dt0 */
|
|
1867
|
+
dtRatio: number;
|
|
1868
|
+
reset(dt: number): void;
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Contact impulses for reporting. Impulses are used instead of forces because
|
|
1872
|
+
* sub-step forces may approach infinity for rigid body collisions. These match
|
|
1873
|
+
* up one-to-one with the contact points in Manifold.
|
|
1874
|
+
*/
|
|
1875
|
+
export declare class ContactImpulse {
|
|
1876
|
+
private readonly contact;
|
|
1877
|
+
private readonly normals;
|
|
1878
|
+
private readonly tangents;
|
|
1879
|
+
constructor(contact: Contact);
|
|
1880
|
+
recycle(): void;
|
|
1881
|
+
get normalImpulses(): number[];
|
|
1882
|
+
get tangentImpulses(): number[];
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* Finds and solves islands. An island is a connected subset of the world.
|
|
1886
|
+
*/
|
|
1887
|
+
export declare class Solver {
|
|
1888
|
+
m_world: World;
|
|
1889
|
+
m_stack: Body$1[];
|
|
1890
|
+
m_bodies: Body$1[];
|
|
1891
|
+
m_contacts: Contact[];
|
|
1892
|
+
m_joints: Joint[];
|
|
1893
|
+
constructor(world: World);
|
|
1894
|
+
clear(): void;
|
|
1895
|
+
addBody(body: Body$1): void;
|
|
1896
|
+
addContact(contact: Contact): void;
|
|
1897
|
+
addJoint(joint: Joint): void;
|
|
1898
|
+
solveWorld(step: TimeStep): void;
|
|
1899
|
+
solveIsland(step: TimeStep): void;
|
|
1900
|
+
/**
|
|
1901
|
+
* Find TOI contacts and solve them.
|
|
1902
|
+
*/
|
|
1903
|
+
solveWorldTOI(step: TimeStep): void;
|
|
1904
|
+
solveIslandTOI(subStep: TimeStep, toiA: Body$1, toiB: Body$1): void;
|
|
1905
|
+
}
|
|
1906
|
+
export interface WorldDef {
|
|
1907
|
+
/** [default: { x : 0, y : 0}] */
|
|
1908
|
+
gravity?: Vec2Value;
|
|
1909
|
+
/** [default: true] */
|
|
1910
|
+
allowSleep?: boolean;
|
|
1911
|
+
/** [default: true] */
|
|
1912
|
+
warmStarting?: boolean;
|
|
1913
|
+
/** [default: true] */
|
|
1914
|
+
continuousPhysics?: boolean;
|
|
1915
|
+
/** [default: false] */
|
|
1916
|
+
subStepping?: boolean;
|
|
1917
|
+
/** [default: true] */
|
|
1918
|
+
blockSolve?: boolean;
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Callback function for ray casts, see {@link World.rayCast}.
|
|
1922
|
+
*
|
|
1923
|
+
* Called for each fixture found in the query.
|
|
1924
|
+
* The returned value replaces the ray-cast input maxFraction.
|
|
1925
|
+
* You control how the ray cast proceeds by returning a numeric/float value.
|
|
1926
|
+
*
|
|
1927
|
+
* - `0` to terminate the ray cast
|
|
1928
|
+
* - `fraction` to clip the ray cast at current point
|
|
1929
|
+
* - `1` don't clip the ray and continue
|
|
1930
|
+
* - `-1` (or anything else) to continue
|
|
1931
|
+
*
|
|
1932
|
+
* @param fixture The fixture hit by the ray
|
|
1933
|
+
* @param point The point of initial intersection
|
|
1934
|
+
* @param normal The normal vector at the point of intersection
|
|
1935
|
+
* @param fraction The fraction along the ray at the point of intersection
|
|
1936
|
+
*
|
|
1937
|
+
* @returns A number to update the maxFraction
|
|
1938
|
+
*/
|
|
1939
|
+
export type WorldRayCastCallback = (fixture: Fixture, point: Vec2Value, normal: Vec2Value, fraction: number) => number;
|
|
1940
|
+
/**
|
|
1941
|
+
* Called for each fixture found in the query AABB. It may return `false` to terminate the query.
|
|
1942
|
+
*/
|
|
1943
|
+
export type WorldAABBQueryCallback = (fixture: Fixture) => boolean;
|
|
1944
|
+
/**
|
|
1945
|
+
* The `World` class contains the bodies and joints. It manages all aspects
|
|
1946
|
+
* of the simulation and allows for asynchronous queries (like AABB queries
|
|
1947
|
+
* and ray-casts). Much of your interactions with Planck.js will be with a
|
|
1948
|
+
* World object.
|
|
1949
|
+
*/
|
|
1950
|
+
export declare class World {
|
|
1951
|
+
/**
|
|
1952
|
+
* @param def World definition or gravity vector.
|
|
1953
|
+
*/
|
|
1954
|
+
constructor(def?: WorldDef | Vec2Value);
|
|
1955
|
+
/** @hidden */
|
|
1956
|
+
_serialize(): object;
|
|
1957
|
+
/** @hidden */
|
|
1958
|
+
static _deserialize(data: any, context: any, restore: any): World;
|
|
1959
|
+
/**
|
|
1960
|
+
* Get the world body list. With the returned body, use Body.getNext to get the
|
|
1961
|
+
* next body in the world list. A null body indicates the end of the list.
|
|
1962
|
+
*
|
|
1963
|
+
* @return the head of the world body list.
|
|
1964
|
+
*/
|
|
1965
|
+
getBodyList(): Body$1 | null;
|
|
1966
|
+
/**
|
|
1967
|
+
* Get the world joint list. With the returned joint, use Joint.getNext to get
|
|
1968
|
+
* the next joint in the world list. A null joint indicates the end of the list.
|
|
1969
|
+
*
|
|
1970
|
+
* @return the head of the world joint list.
|
|
1971
|
+
*/
|
|
1972
|
+
getJointList(): Joint | null;
|
|
1973
|
+
/**
|
|
1974
|
+
* Get the world contact list. With the returned contact, use Contact.getNext to
|
|
1975
|
+
* get the next contact in the world list. A null contact indicates the end of
|
|
1976
|
+
* the list.
|
|
1977
|
+
*
|
|
1978
|
+
* Warning: contacts are created and destroyed in the middle of a time step.
|
|
1979
|
+
* Use ContactListener to avoid missing contacts.
|
|
1980
|
+
*
|
|
1981
|
+
* @return the head of the world contact list.
|
|
1982
|
+
*/
|
|
1983
|
+
getContactList(): Contact | null;
|
|
1984
|
+
getBodyCount(): number;
|
|
1985
|
+
getJointCount(): number;
|
|
1986
|
+
/**
|
|
1987
|
+
* Get the number of contacts (each may have 0 or more contact points).
|
|
1988
|
+
*/
|
|
1989
|
+
getContactCount(): number;
|
|
1990
|
+
/**
|
|
1991
|
+
* Change the global gravity vector.
|
|
1992
|
+
*/
|
|
1993
|
+
setGravity(gravity: Vec2Value): void;
|
|
1994
|
+
/**
|
|
1995
|
+
* Get the global gravity vector.
|
|
1996
|
+
*/
|
|
1997
|
+
getGravity(): Vec2Value;
|
|
1998
|
+
/**
|
|
1999
|
+
* Is the world locked (in the middle of a time step).
|
|
2000
|
+
*/
|
|
2001
|
+
isLocked(): boolean;
|
|
2002
|
+
/**
|
|
2003
|
+
* Enable/disable sleep.
|
|
2004
|
+
*/
|
|
2005
|
+
setAllowSleeping(flag: boolean): void;
|
|
2006
|
+
getAllowSleeping(): boolean;
|
|
2007
|
+
/**
|
|
2008
|
+
* Enable/disable warm starting. For testing.
|
|
2009
|
+
*/
|
|
2010
|
+
setWarmStarting(flag: boolean): void;
|
|
2011
|
+
getWarmStarting(): boolean;
|
|
2012
|
+
/**
|
|
2013
|
+
* Enable/disable continuous physics. For testing.
|
|
2014
|
+
*/
|
|
2015
|
+
setContinuousPhysics(flag: boolean): void;
|
|
2016
|
+
getContinuousPhysics(): boolean;
|
|
2017
|
+
/**
|
|
2018
|
+
* Enable/disable single stepped continuous physics. For testing.
|
|
2019
|
+
*/
|
|
2020
|
+
setSubStepping(flag: boolean): void;
|
|
2021
|
+
getSubStepping(): boolean;
|
|
2022
|
+
/**
|
|
2023
|
+
* Set flag to control automatic clearing of forces after each time step.
|
|
2024
|
+
*/
|
|
2025
|
+
setAutoClearForces(flag: boolean): void;
|
|
2026
|
+
/**
|
|
2027
|
+
* Get the flag that controls automatic clearing of forces after each time step.
|
|
2028
|
+
*/
|
|
2029
|
+
getAutoClearForces(): boolean;
|
|
2030
|
+
/**
|
|
2031
|
+
* Manually clear the force buffer on all bodies. By default, forces are cleared
|
|
2032
|
+
* automatically after each call to step. The default behavior is modified by
|
|
2033
|
+
* calling setAutoClearForces. The purpose of this function is to support
|
|
2034
|
+
* sub-stepping. Sub-stepping is often used to maintain a fixed sized time step
|
|
2035
|
+
* under a variable frame-rate. When you perform sub-stepping you will disable
|
|
2036
|
+
* auto clearing of forces and instead call clearForces after all sub-steps are
|
|
2037
|
+
* complete in one pass of your game loop.
|
|
2038
|
+
*
|
|
2039
|
+
* See {@link World.setAutoClearForces}
|
|
2040
|
+
*/
|
|
2041
|
+
clearForces(): void;
|
|
2042
|
+
/**
|
|
2043
|
+
* Query the world for all fixtures that potentially overlap the provided AABB.
|
|
2044
|
+
*
|
|
2045
|
+
* @param aabb The query box.
|
|
2046
|
+
* @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.
|
|
2047
|
+
*/
|
|
2048
|
+
queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void;
|
|
2049
|
+
/**
|
|
2050
|
+
* Ray-cast the world for all fixtures in the path of the ray. Your callback
|
|
2051
|
+
* controls whether you get the closest point, any point, or n-points. The
|
|
2052
|
+
* ray-cast ignores shapes that contain the starting point.
|
|
2053
|
+
*
|
|
2054
|
+
* @param point1 The ray starting point
|
|
2055
|
+
* @param point2 The ray ending point
|
|
2056
|
+
* @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.
|
|
2057
|
+
*/
|
|
2058
|
+
rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void;
|
|
2059
|
+
/**
|
|
2060
|
+
* Get the number of broad-phase proxies.
|
|
2061
|
+
*/
|
|
2062
|
+
getProxyCount(): number;
|
|
2063
|
+
/**
|
|
2064
|
+
* Get the height of broad-phase dynamic tree.
|
|
2065
|
+
*/
|
|
2066
|
+
getTreeHeight(): number;
|
|
2067
|
+
/**
|
|
2068
|
+
* Get the balance of broad-phase dynamic tree.
|
|
2069
|
+
*/
|
|
2070
|
+
getTreeBalance(): number;
|
|
2071
|
+
/**
|
|
2072
|
+
* Get the quality metric of broad-phase dynamic tree. The smaller the better.
|
|
2073
|
+
* The minimum is 1.
|
|
2074
|
+
*/
|
|
2075
|
+
getTreeQuality(): number;
|
|
2076
|
+
/**
|
|
2077
|
+
* Shift the world origin. Useful for large worlds. The body shift formula is:
|
|
2078
|
+
* position -= newOrigin
|
|
2079
|
+
*
|
|
2080
|
+
* @param newOrigin The new origin with respect to the old origin
|
|
2081
|
+
*
|
|
2082
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
2083
|
+
*/
|
|
2084
|
+
shiftOrigin(newOrigin: Vec2Value): void;
|
|
2085
|
+
/**
|
|
2086
|
+
* Create a rigid body given a definition. No reference to the definition is
|
|
2087
|
+
* retained.
|
|
2088
|
+
*
|
|
2089
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
2090
|
+
*/
|
|
2091
|
+
createBody(def?: BodyDef): Body$1;
|
|
2092
|
+
createBody(position: Vec2Value, angle?: number): Body$1;
|
|
2093
|
+
createDynamicBody(def?: BodyDef): Body$1;
|
|
2094
|
+
createDynamicBody(position: Vec2Value, angle?: number): Body$1;
|
|
2095
|
+
createKinematicBody(def?: BodyDef): Body$1;
|
|
2096
|
+
createKinematicBody(position: Vec2Value, angle?: number): Body$1;
|
|
2097
|
+
/**
|
|
2098
|
+
* Destroy a body from the world.
|
|
2099
|
+
*
|
|
2100
|
+
* Warning: This automatically deletes all associated shapes and joints.
|
|
2101
|
+
*
|
|
2102
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
2103
|
+
*/
|
|
2104
|
+
destroyBody(b: Body$1): boolean;
|
|
2105
|
+
/**
|
|
2106
|
+
* Create a joint to constrain bodies together. No reference to the definition
|
|
2107
|
+
* is retained. This may cause the connected bodies to cease colliding.
|
|
2108
|
+
*
|
|
2109
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
2110
|
+
*/
|
|
2111
|
+
createJoint<T extends Joint>(joint: T): T | null;
|
|
2112
|
+
/**
|
|
2113
|
+
* Destroy a joint.
|
|
2114
|
+
*
|
|
2115
|
+
* Warning: This may cause the connected bodies to begin colliding.
|
|
2116
|
+
*
|
|
2117
|
+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
|
|
2118
|
+
*/
|
|
2119
|
+
destroyJoint(joint: Joint): void;
|
|
2120
|
+
/**
|
|
2121
|
+
* Take a time step. This performs collision detection, integration, and
|
|
2122
|
+
* constraint solution.
|
|
2123
|
+
*
|
|
2124
|
+
* Broad-phase, narrow-phase, solve and solve time of impacts.
|
|
2125
|
+
*
|
|
2126
|
+
* @param timeStep Time step, this should not vary.
|
|
2127
|
+
*/
|
|
2128
|
+
step(timeStep: number, velocityIterations?: number, positionIterations?: number): void;
|
|
2129
|
+
/**
|
|
2130
|
+
* Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.
|
|
2131
|
+
*/
|
|
2132
|
+
queueUpdate(callback: (world: World) => unknown): void;
|
|
2133
|
+
/**
|
|
2134
|
+
* Called when two fixtures begin to touch.
|
|
2135
|
+
*
|
|
2136
|
+
* Implement contact callbacks to get contact information. You can use these
|
|
2137
|
+
* results for things like sounds and game logic. You can also get contact
|
|
2138
|
+
* results by traversing the contact lists after the time step. However, you
|
|
2139
|
+
* might miss some contacts because continuous physics leads to sub-stepping.
|
|
2140
|
+
* Additionally you may receive multiple callbacks for the same contact in a
|
|
2141
|
+
* single time step. You should strive to make your callbacks efficient because
|
|
2142
|
+
* there may be many callbacks per time step.
|
|
2143
|
+
*
|
|
2144
|
+
* Warning: You cannot create/destroy world entities inside these callbacks.
|
|
2145
|
+
*/
|
|
2146
|
+
on(name: "begin-contact", listener: (contact: Contact) => void): World;
|
|
2147
|
+
/**
|
|
2148
|
+
* Called when two fixtures cease to touch.
|
|
2149
|
+
*
|
|
2150
|
+
* Implement contact callbacks to get contact information. You can use these
|
|
2151
|
+
* results for things like sounds and game logic. You can also get contact
|
|
2152
|
+
* results by traversing the contact lists after the time step. However, you
|
|
2153
|
+
* might miss some contacts because continuous physics leads to sub-stepping.
|
|
2154
|
+
* Additionally you may receive multiple callbacks for the same contact in a
|
|
2155
|
+
* single time step. You should strive to make your callbacks efficient because
|
|
2156
|
+
* there may be many callbacks per time step.
|
|
2157
|
+
*
|
|
2158
|
+
* Warning: You cannot create/destroy world entities inside these callbacks.
|
|
2159
|
+
*/
|
|
2160
|
+
on(name: "end-contact", listener: (contact: Contact) => void): World;
|
|
2161
|
+
/**
|
|
2162
|
+
* This is called after a contact is updated. This allows you to inspect a
|
|
2163
|
+
* contact before it goes to the solver. If you are careful, you can modify the
|
|
2164
|
+
* contact manifold (e.g. disable contact). A copy of the old manifold is
|
|
2165
|
+
* provided so that you can detect changes. Note: this is called only for awake
|
|
2166
|
+
* bodies. Note: this is called even when the number of contact points is zero.
|
|
2167
|
+
* Note: this is not called for sensors. Note: if you set the number of contact
|
|
2168
|
+
* points to zero, you will not get an end-contact callback. However, you may get
|
|
2169
|
+
* a begin-contact callback the next step.
|
|
2170
|
+
*
|
|
2171
|
+
* Warning: You cannot create/destroy world entities inside these callbacks.
|
|
2172
|
+
*/
|
|
2173
|
+
on(name: "pre-solve", listener: (contact: Contact, oldManifold: Manifold) => void): World;
|
|
2174
|
+
/**
|
|
2175
|
+
* This lets you inspect a contact after the solver is finished. This is useful
|
|
2176
|
+
* for inspecting impulses. Note: the contact manifold does not include time of
|
|
2177
|
+
* impact impulses, which can be arbitrarily large if the sub-step is small.
|
|
2178
|
+
* Hence the impulse is provided explicitly in a separate data structure. Note:
|
|
2179
|
+
* this is only called for contacts that are touching, solid, and awake.
|
|
2180
|
+
*
|
|
2181
|
+
* Warning: You cannot create/destroy world entities inside these callbacks.
|
|
2182
|
+
*/
|
|
2183
|
+
on(name: "post-solve", listener: (contact: Contact, impulse: ContactImpulse) => void): World;
|
|
2184
|
+
/** Listener is called whenever a body is removed. */
|
|
2185
|
+
on(name: "remove-body", listener: (body: Body$1) => void): World;
|
|
2186
|
+
/** Listener is called whenever a joint is removed implicitly or explicitly. */
|
|
2187
|
+
on(name: "remove-joint", listener: (joint: Joint) => void): World;
|
|
2188
|
+
/** Listener is called whenever a fixture is removed implicitly or explicitly. */
|
|
2189
|
+
on(name: "remove-fixture", listener: (fixture: Fixture) => void): World;
|
|
2190
|
+
off(name: "begin-contact", listener: (contact: Contact) => void): World;
|
|
2191
|
+
off(name: "end-contact", listener: (contact: Contact) => void): World;
|
|
2192
|
+
off(name: "pre-solve", listener: (contact: Contact, oldManifold: Manifold) => void): World;
|
|
2193
|
+
off(name: "post-solve", listener: (contact: Contact, impulse: ContactImpulse) => void): World;
|
|
2194
|
+
off(name: "remove-body", listener: (body: Body$1) => void): World;
|
|
2195
|
+
off(name: "remove-joint", listener: (joint: Joint) => void): World;
|
|
2196
|
+
off(name: "remove-fixture", listener: (fixture: Fixture) => void): World;
|
|
2197
|
+
publish(name: string, arg1?: any, arg2?: any, arg3?: any): number;
|
|
2198
|
+
}
|
|
2199
|
+
export type DataType = any;
|
|
2200
|
+
export type ObjectType = any;
|
|
2201
|
+
export type ClassName = any;
|
|
2202
|
+
export type SerializedType = object[];
|
|
2203
|
+
export type SerializerOptions = {
|
|
2204
|
+
rootClass: ClassName;
|
|
2205
|
+
preSerialize?: (obj: ObjectType) => DataType;
|
|
2206
|
+
postSerialize?: (data: DataType, obj: any) => DataType;
|
|
2207
|
+
preDeserialize?: (data: DataType) => DataType;
|
|
2208
|
+
postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType;
|
|
2209
|
+
};
|
|
2210
|
+
export declare class Serializer<T> {
|
|
2211
|
+
private options;
|
|
2212
|
+
constructor(options: SerializerOptions);
|
|
2213
|
+
toJson: (root: T) => SerializedType;
|
|
2214
|
+
fromJson: (json: SerializedType) => T;
|
|
2215
|
+
static toJson: (root: World) => SerializedType;
|
|
2216
|
+
static fromJson: (json: SerializedType) => World;
|
|
2217
|
+
}
|
|
2218
|
+
/** @ignore */
|
|
2219
|
+
declare const math: any;
|
|
2220
|
+
/** 3D vector */
|
|
2221
|
+
export interface Vec3Value {
|
|
2222
|
+
x: number;
|
|
2223
|
+
y: number;
|
|
2224
|
+
z: number;
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* 3D vector
|
|
2228
|
+
*
|
|
2229
|
+
* @deprecated Use Vec3Value and geo functions instead.
|
|
2230
|
+
*/
|
|
2231
|
+
export declare class Vec3 {
|
|
2232
|
+
x: number;
|
|
2233
|
+
y: number;
|
|
2234
|
+
z: number;
|
|
2235
|
+
constructor(x: number, y: number, z: number);
|
|
2236
|
+
constructor(obj: Vec3Value);
|
|
2237
|
+
constructor();
|
|
2238
|
+
/** @hidden */
|
|
2239
|
+
_serialize(): object;
|
|
2240
|
+
/** @hidden */
|
|
2241
|
+
static _deserialize(data: any): Vec3;
|
|
2242
|
+
/** @hidden */
|
|
2243
|
+
static neo(x: number, y: number, z: number): Vec3;
|
|
2244
|
+
static zero(): Vec3;
|
|
2245
|
+
static clone(v: Vec3Value): Vec3;
|
|
2246
|
+
/** @hidden */
|
|
2247
|
+
toString(): string;
|
|
2248
|
+
/** Does this vector contain finite coordinates? */
|
|
2249
|
+
static isValid(obj: any): boolean;
|
|
2250
|
+
static assert(o: any): void;
|
|
2251
|
+
setZero(): Vec3;
|
|
2252
|
+
set(x: number, y: number, z: number): Vec3;
|
|
2253
|
+
add(w: Vec3Value): Vec3;
|
|
2254
|
+
sub(w: Vec3Value): Vec3;
|
|
2255
|
+
mul(m: number): Vec3;
|
|
2256
|
+
static areEqual(v: Vec3Value, w: Vec3Value): boolean;
|
|
2257
|
+
/** Dot product on two vectors */
|
|
2258
|
+
static dot(v: Vec3Value, w: Vec3Value): number;
|
|
2259
|
+
/** Cross product on two vectors */
|
|
2260
|
+
static cross(v: Vec3Value, w: Vec3Value): Vec3;
|
|
2261
|
+
static add(v: Vec3Value, w: Vec3Value): Vec3;
|
|
2262
|
+
static sub(v: Vec3Value, w: Vec3Value): Vec3;
|
|
2263
|
+
static mul(v: Vec3Value, m: number): Vec3;
|
|
2264
|
+
neg(): Vec3;
|
|
2265
|
+
static neg(v: Vec3Value): Vec3;
|
|
2266
|
+
}
|
|
2267
|
+
/** A 2-by-2 matrix. Stored in column-major order. */
|
|
2268
|
+
export interface Mat22Value {
|
|
2269
|
+
ex: Vec2Value;
|
|
2270
|
+
ey: Vec2Value;
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* A 2-by-2 matrix. Stored in column-major order.
|
|
2274
|
+
*
|
|
2275
|
+
* @deprecated Use Mat22Value and geo functions instead.
|
|
2276
|
+
*/
|
|
2277
|
+
export declare class Mat22 {
|
|
2278
|
+
ex: Vec2;
|
|
2279
|
+
ey: Vec2;
|
|
2280
|
+
constructor(a: number, b: number, c: number, d: number);
|
|
2281
|
+
constructor(a: {
|
|
2282
|
+
x: number;
|
|
2283
|
+
y: number;
|
|
2284
|
+
}, b: {
|
|
2285
|
+
x: number;
|
|
2286
|
+
y: number;
|
|
2287
|
+
});
|
|
2288
|
+
constructor();
|
|
2289
|
+
/** @hidden */
|
|
2290
|
+
toString(): string;
|
|
2291
|
+
static isValid(obj: any): boolean;
|
|
2292
|
+
static assert(o: any): void;
|
|
2293
|
+
set(a: Mat22): void;
|
|
2294
|
+
set(a: Vec2Value, b: Vec2Value): void;
|
|
2295
|
+
set(a: number, b: number, c: number, d: number): void;
|
|
2296
|
+
setIdentity(): void;
|
|
2297
|
+
setZero(): void;
|
|
2298
|
+
getInverse(): Mat22;
|
|
2299
|
+
/**
|
|
2300
|
+
* Solve A * x = b, where b is a column vector. This is more efficient than
|
|
2301
|
+
* computing the inverse in one-shot cases.
|
|
2302
|
+
*/
|
|
2303
|
+
solve(v: Vec2Value): Vec2;
|
|
2304
|
+
/**
|
|
2305
|
+
* Multiply a matrix times a vector. If a rotation matrix is provided, then this
|
|
2306
|
+
* transforms the vector from one frame to another.
|
|
2307
|
+
*/
|
|
2308
|
+
static mul(mx: Mat22, my: Mat22): Mat22;
|
|
2309
|
+
static mul(mx: Mat22, v: Vec2Value): Vec2;
|
|
2310
|
+
static mulVec2(mx: Mat22, v: Vec2Value): Vec2;
|
|
2311
|
+
static mulMat22(mx: Mat22, v: Mat22): Mat22;
|
|
2312
|
+
/**
|
|
2313
|
+
* Multiply a matrix transpose times a vector. If a rotation matrix is provided,
|
|
2314
|
+
* then this transforms the vector from one frame to another (inverse
|
|
2315
|
+
* transform).
|
|
2316
|
+
*/
|
|
2317
|
+
static mulT(mx: Mat22, my: Mat22): Mat22;
|
|
2318
|
+
static mulT(mx: Mat22, v: Vec2Value): Vec2;
|
|
2319
|
+
static mulTVec2(mx: Mat22, v: Vec2Value): Vec2;
|
|
2320
|
+
static mulTMat22(mx: Mat22, v: Mat22): Mat22;
|
|
2321
|
+
static abs(mx: Mat22): Mat22;
|
|
2322
|
+
static add(mx1: Mat22, mx2: Mat22): Mat22;
|
|
2323
|
+
}
|
|
2324
|
+
/** A 3-by-3 matrix. Stored in column-major order. */
|
|
2325
|
+
export interface Mat33Value {
|
|
2326
|
+
ex: Vec3Value;
|
|
2327
|
+
ey: Vec3Value;
|
|
2328
|
+
ez: Vec3Value;
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* A 3-by-3 matrix. Stored in column-major order.
|
|
2332
|
+
*
|
|
2333
|
+
* @deprecated Use Mat33Value and geo functions instead.
|
|
2334
|
+
*/
|
|
2335
|
+
export declare class Mat33 {
|
|
2336
|
+
ex: Vec3;
|
|
2337
|
+
ey: Vec3;
|
|
2338
|
+
ez: Vec3;
|
|
2339
|
+
constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);
|
|
2340
|
+
constructor();
|
|
2341
|
+
/** @hidden */
|
|
2342
|
+
toString(): string;
|
|
2343
|
+
static isValid(obj: any): boolean;
|
|
2344
|
+
static assert(o: any): void;
|
|
2345
|
+
/**
|
|
2346
|
+
* Set this matrix to all zeros.
|
|
2347
|
+
*/
|
|
2348
|
+
setZero(): Mat33;
|
|
2349
|
+
/**
|
|
2350
|
+
* Solve A * x = b, where b is a column vector. This is more efficient than
|
|
2351
|
+
* computing the inverse in one-shot cases.
|
|
2352
|
+
*/
|
|
2353
|
+
solve33(v: Vec3Value): Vec3;
|
|
2354
|
+
/**
|
|
2355
|
+
* Solve A * x = b, where b is a column vector. This is more efficient than
|
|
2356
|
+
* computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix
|
|
2357
|
+
* equation.
|
|
2358
|
+
*/
|
|
2359
|
+
solve22(v: Vec2Value): Vec2;
|
|
2360
|
+
/**
|
|
2361
|
+
* Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if
|
|
2362
|
+
* singular.
|
|
2363
|
+
*/
|
|
2364
|
+
getInverse22(M: Mat33): void;
|
|
2365
|
+
/**
|
|
2366
|
+
* Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix
|
|
2367
|
+
* if singular.
|
|
2368
|
+
*/
|
|
2369
|
+
getSymInverse33(M: Mat33): void;
|
|
2370
|
+
/**
|
|
2371
|
+
* Multiply a matrix times a vector.
|
|
2372
|
+
*/
|
|
2373
|
+
static mul(a: Mat33, b: Vec2Value): Vec2;
|
|
2374
|
+
static mul(a: Mat33, b: Vec3Value): Vec3;
|
|
2375
|
+
static mulVec3(a: Mat33, b: Vec3Value): Vec3;
|
|
2376
|
+
static mulVec2(a: Mat33, b: Vec2Value): Vec2;
|
|
2377
|
+
static add(a: Mat33, b: Mat33): Mat33;
|
|
2378
|
+
}
|
|
2379
|
+
declare function vec2(inx: number, iny: number): Vec2Value;
|
|
2380
|
+
declare function vec3(inx: number, iny: number, inz: number): Vec3Value;
|
|
2381
|
+
declare function rotation(angle: number): RotValue;
|
|
2382
|
+
declare function setVec2(out: Vec2Value, inx: number, iny: number): void;
|
|
2383
|
+
declare function setVec3(out: Vec3Value, x: number, y: number, z: number): void;
|
|
2384
|
+
declare function copyVec2(out: Vec2Value, w: Vec2Value): void;
|
|
2385
|
+
declare function copyVec3(out: Vec2Value, w: Vec2Value): void;
|
|
2386
|
+
declare function zeroVec2(out: Vec2Value): void;
|
|
2387
|
+
declare function zeroVec3(out: Vec3Value): void;
|
|
2388
|
+
declare function negVec2(out: Vec2Value): void;
|
|
2389
|
+
declare function negVec3(out: Vec3Value): void;
|
|
2390
|
+
declare function plusVec2(out: Vec2Value, w: Vec2Value): void;
|
|
2391
|
+
declare function plusVec3(out: Vec3Value, w: Vec3Value): void;
|
|
2392
|
+
declare function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): void;
|
|
2393
|
+
declare function clampVec2(out: Vec2Value, max: number): void;
|
|
2394
|
+
declare function minusVec2(out: Vec2Value, w: Vec2Value): void;
|
|
2395
|
+
declare function minusCrossNumVec2(out: Vec2Value, w: number, v: Vec2Value): void;
|
|
2396
|
+
declare function plusCrossNumVec2(out: Vec2Value, w: number, v: Vec2Value): void;
|
|
2397
|
+
declare function dotCrossNumVec2(i: Vec2Value, w: number, v: Vec2Value): number;
|
|
2398
|
+
declare function dotSubVec2(a: Vec2Value, b: Vec2Value, c: Vec2Value): number;
|
|
2399
|
+
declare function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): void;
|
|
2400
|
+
declare function absVec2(out: Vec2Value, v: Vec2Value): void;
|
|
2401
|
+
declare function mulVec2(out: Vec2Value, m: number): void;
|
|
2402
|
+
declare function mulVec3(out: Vec3Value, m: number): void;
|
|
2403
|
+
declare function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): void;
|
|
2404
|
+
declare function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): void;
|
|
2405
|
+
declare function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): void;
|
|
2406
|
+
declare function crossSubVec2Num(out: Vec2Value, a: Vec2Value, b: Vec2Value, w: number): void;
|
|
2407
|
+
declare function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): void;
|
|
2408
|
+
declare function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): void;
|
|
2409
|
+
declare function combine4Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value, dm: number, d: Vec2Value): void;
|
|
2410
|
+
declare function normalizeVec2Length(out: Vec2Value): number;
|
|
2411
|
+
declare function normalizeVec2(out: Vec2Value): void;
|
|
2412
|
+
declare function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): void;
|
|
2413
|
+
declare function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): void;
|
|
2414
|
+
declare function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number;
|
|
2415
|
+
declare function dotVec2(a: Vec2Value, b: Vec2Value): number;
|
|
2416
|
+
declare function lengthVec2(a: Vec2Value): number;
|
|
2417
|
+
declare function lengthSqrVec2(a: Vec2Value): number;
|
|
2418
|
+
declare function distVec2(a: Vec2Value, b: Vec2Value): number;
|
|
2419
|
+
declare function distSqrVec2(a: Vec2Value, b: Vec2Value): number;
|
|
2420
|
+
declare function dotVec3(v: Vec3Value, w: Vec3Value): number;
|
|
2421
|
+
declare function setRotAngle(out: RotValue, a: number): void;
|
|
2422
|
+
declare function getRotAngle(out: RotValue): number;
|
|
2423
|
+
declare function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): void;
|
|
2424
|
+
declare function rotSubVec2(out: Vec2Value, q: RotValue, v: Vec2Value, w: Vec2Value): void;
|
|
2425
|
+
declare function rotNegVec2(out: Vec2Value, q: RotValue, w: Vec2Value): void;
|
|
2426
|
+
declare function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): void;
|
|
2427
|
+
declare function derotNegVec2(out: Vec2Value, q: RotValue, v: Vec2Value): void;
|
|
2428
|
+
declare function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): void;
|
|
2429
|
+
declare function transform(inx: number, iny: number, ina: number): TransformValue;
|
|
2430
|
+
declare function setTransform(xf: TransformValue, inx: number, iny: number, ina: number): void;
|
|
2431
|
+
declare function copyTransform(out: TransformValue, transform: TransformValue): void;
|
|
2432
|
+
declare function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): void;
|
|
2433
|
+
declare function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): void;
|
|
2434
|
+
declare function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): void;
|
|
2435
|
+
declare function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): void;
|
|
2436
|
+
declare function mat22(): Mat22Value;
|
|
2437
|
+
declare function mat33(): {
|
|
2438
|
+
ex: {
|
|
2439
|
+
x: number;
|
|
2440
|
+
y: number;
|
|
2441
|
+
z: number;
|
|
2442
|
+
};
|
|
2443
|
+
ey: {
|
|
2444
|
+
x: number;
|
|
2445
|
+
y: number;
|
|
2446
|
+
z: number;
|
|
2447
|
+
};
|
|
2448
|
+
ez: {
|
|
2449
|
+
x: number;
|
|
2450
|
+
y: number;
|
|
2451
|
+
z: number;
|
|
2452
|
+
};
|
|
2453
|
+
};
|
|
2454
|
+
declare function zeroMat22(out: Mat22Value): void;
|
|
2455
|
+
declare function zeroMat33(out: Mat33Value): void;
|
|
2456
|
+
declare function mulMat22Vec2(out: Vec2Value, m: Mat22Value, v: Vec2Value): void;
|
|
2457
|
+
declare function mulMat33Vec2(out: Vec2Value, m: Mat33Value, v: Vec2Value): void;
|
|
2458
|
+
declare function mulMat33Vec3(out: Vec3Value, m: Mat33Value, v: Vec3Value): void;
|
|
2459
|
+
declare function inverseMat22(out: Mat22Value, m: Mat22Value): void;
|
|
2460
|
+
declare function symInverseMat33(out: Mat33Value, m: Mat33Value): void;
|
|
2461
|
+
declare function solveMat22Num(out: Vec2Value, m: Mat22Value, x: number, y: number): void;
|
|
2462
|
+
declare function solveMat33Num(out: Vec3Value, m: Mat33Value, x: number, y: number, z: number): void;
|
|
2463
|
+
declare function vp(out: Vec2Value, v: Vec2Value, w: number, r: Vec2Value): void;
|
|
2464
|
+
declare function dvp(out: Vec2Value, vB: Vec2Value, wB: number, rB: Vec2Value, vA: Vec2Value, wA: number, rA: Vec2Value): void;
|
|
2465
|
+
declare function isVec2(obj: any): boolean;
|
|
2466
|
+
/** Circle shape. */
|
|
2467
|
+
export declare class CircleShape extends Shape {
|
|
2468
|
+
static TYPE: "circle";
|
|
2469
|
+
/** @hidden */ m_type: "circle";
|
|
2470
|
+
/** @hidden */ m_p: Vec2Value;
|
|
2471
|
+
/** @hidden */ m_radius: number;
|
|
2472
|
+
constructor(position: Vec2Value, radius?: number);
|
|
2473
|
+
constructor(radius?: number);
|
|
2474
|
+
/** @hidden */
|
|
2475
|
+
_serialize(): object;
|
|
2476
|
+
/** @hidden */
|
|
2477
|
+
static _deserialize(data: any): CircleShape;
|
|
2478
|
+
/** @hidden */
|
|
2479
|
+
_reset(): void;
|
|
2480
|
+
getType(): "circle";
|
|
2481
|
+
getRadius(): number;
|
|
2482
|
+
getCenter(): Vec2Value;
|
|
2483
|
+
/**
|
|
2484
|
+
* Get the number of child primitives.
|
|
2485
|
+
*/
|
|
2486
|
+
getChildCount(): 1;
|
|
2487
|
+
/**
|
|
2488
|
+
* Test a point for containment in this shape. This only works for convex
|
|
2489
|
+
* shapes.
|
|
2490
|
+
*
|
|
2491
|
+
* @param xf The shape world transform.
|
|
2492
|
+
* @param p A point in world coordinates.
|
|
2493
|
+
*/
|
|
2494
|
+
testPoint(xf: TransformValue, p: Vec2Value): boolean;
|
|
2495
|
+
/**
|
|
2496
|
+
* Cast a ray against a child shape.
|
|
2497
|
+
*
|
|
2498
|
+
* @param output The ray-cast results.
|
|
2499
|
+
* @param input The ray-cast input parameters.
|
|
2500
|
+
* @param xf The transform to be applied to the shape.
|
|
2501
|
+
* @param childIndex The child shape index
|
|
2502
|
+
*/
|
|
2503
|
+
rayCast(output: RayCastOutput, input: RayCastInput, xf: TransformValue, childIndex: number): boolean;
|
|
2504
|
+
/**
|
|
2505
|
+
* Given a transform, compute the associated axis aligned bounding box for a
|
|
2506
|
+
* child shape.
|
|
2507
|
+
*
|
|
2508
|
+
* @param aabb Returns the axis aligned box.
|
|
2509
|
+
* @param xf The world transform of the shape.
|
|
2510
|
+
* @param childIndex The child shape
|
|
2511
|
+
*/
|
|
2512
|
+
computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;
|
|
2513
|
+
/**
|
|
2514
|
+
* Compute the mass properties of this shape using its dimensions and density.
|
|
2515
|
+
* The inertia tensor is computed about the local origin.
|
|
2516
|
+
*
|
|
2517
|
+
* @param massData Returns the mass data for this shape.
|
|
2518
|
+
* @param density The density in kilograms per meter squared.
|
|
2519
|
+
*/
|
|
2520
|
+
computeMass(massData: MassData, density: number): void;
|
|
2521
|
+
computeDistanceProxy(proxy: DistanceProxy): void;
|
|
2522
|
+
}
|
|
2523
|
+
/**
|
|
2524
|
+
* A line segment (edge) shape. These can be connected in chains or loops to
|
|
2525
|
+
* other edge shapes. The connectivity information is used to ensure correct
|
|
2526
|
+
* contact normals.
|
|
2527
|
+
*/
|
|
2528
|
+
export declare class EdgeShape extends Shape {
|
|
2529
|
+
static TYPE: "edge";
|
|
2530
|
+
/** @hidden */ m_type: "edge";
|
|
2531
|
+
/** @hidden */ m_radius: number;
|
|
2532
|
+
/** @hidden */ m_vertex1: Vec2Value;
|
|
2533
|
+
/** @hidden */ m_vertex2: Vec2Value;
|
|
2534
|
+
/** @hidden */ m_vertex0: Vec2Value;
|
|
2535
|
+
/** @hidden */ m_vertex3: Vec2Value;
|
|
2536
|
+
/** @hidden */ m_hasVertex0: boolean;
|
|
2537
|
+
/** @hidden */ m_hasVertex3: boolean;
|
|
2538
|
+
constructor(v1?: Vec2Value, v2?: Vec2Value);
|
|
2539
|
+
/** @hidden */
|
|
2540
|
+
_serialize(): object;
|
|
2541
|
+
/** @hidden */
|
|
2542
|
+
static _deserialize(data: any): EdgeShape;
|
|
2543
|
+
/** @hidden */
|
|
2544
|
+
_reset(): void;
|
|
2545
|
+
getRadius(): number;
|
|
2546
|
+
getType(): "edge";
|
|
2547
|
+
/**
|
|
2548
|
+
* Optional next vertex, used for smooth collision.
|
|
2549
|
+
*/
|
|
2550
|
+
setNextVertex(v?: Vec2Value): EdgeShape;
|
|
2551
|
+
/**
|
|
2552
|
+
* Optional next vertex, used for smooth collision.
|
|
2553
|
+
*/
|
|
2554
|
+
getNextVertex(): Vec2Value;
|
|
2555
|
+
/**
|
|
2556
|
+
* Optional prev vertex, used for smooth collision.
|
|
2557
|
+
*/
|
|
2558
|
+
setPrevVertex(v?: Vec2Value): EdgeShape;
|
|
2559
|
+
/**
|
|
2560
|
+
* Optional prev vertex, used for smooth collision.
|
|
2561
|
+
*/
|
|
2562
|
+
getPrevVertex(): Vec2Value;
|
|
2563
|
+
/**
|
|
2564
|
+
* Set this as an isolated edge.
|
|
2565
|
+
*/
|
|
2566
|
+
_set(v1: Vec2Value, v2: Vec2Value): EdgeShape;
|
|
2567
|
+
/**
|
|
2568
|
+
* Get the number of child primitives.
|
|
2569
|
+
*/
|
|
2570
|
+
getChildCount(): 1;
|
|
2571
|
+
/**
|
|
2572
|
+
* Test a point for containment in this shape. This only works for convex
|
|
2573
|
+
* shapes.
|
|
2574
|
+
*
|
|
2575
|
+
* @param xf The shape world transform.
|
|
2576
|
+
* @param p A point in world coordinates.
|
|
2577
|
+
*/
|
|
2578
|
+
testPoint(xf: TransformValue, p: Vec2Value): false;
|
|
2579
|
+
/**
|
|
2580
|
+
* Cast a ray against a child shape.
|
|
2581
|
+
*
|
|
2582
|
+
* @param output The ray-cast results.
|
|
2583
|
+
* @param input The ray-cast input parameters.
|
|
2584
|
+
* @param xf The transform to be applied to the shape.
|
|
2585
|
+
* @param childIndex The child shape index
|
|
2586
|
+
*/
|
|
2587
|
+
rayCast(output: RayCastOutput, input: RayCastInput, xf: TransformValue, childIndex: number): boolean;
|
|
2588
|
+
/**
|
|
2589
|
+
* Given a transform, compute the associated axis aligned bounding box for a
|
|
2590
|
+
* child shape.
|
|
2591
|
+
*
|
|
2592
|
+
* @param aabb Returns the axis aligned box.
|
|
2593
|
+
* @param xf The world transform of the shape.
|
|
2594
|
+
* @param childIndex The child shape
|
|
2595
|
+
*/
|
|
2596
|
+
computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;
|
|
2597
|
+
/**
|
|
2598
|
+
* Compute the mass properties of this shape using its dimensions and density.
|
|
2599
|
+
* The inertia tensor is computed about the local origin.
|
|
2600
|
+
*
|
|
2601
|
+
* @param massData Returns the mass data for this shape.
|
|
2602
|
+
* @param density The density in kilograms per meter squared.
|
|
2603
|
+
*/
|
|
2604
|
+
computeMass(massData: MassData, density?: number): void;
|
|
2605
|
+
computeDistanceProxy(proxy: DistanceProxy): void;
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* A convex polygon. It is assumed that the interior of the polygon is to the
|
|
2609
|
+
* left of each edge. Polygons have a maximum number of vertices equal to
|
|
2610
|
+
* Settings.maxPolygonVertices. In most cases you should not need many vertices
|
|
2611
|
+
* for a convex polygon. extends Shape
|
|
2612
|
+
*/
|
|
2613
|
+
export declare class PolygonShape extends Shape {
|
|
2614
|
+
static TYPE: "polygon";
|
|
2615
|
+
/** @hidden */ m_type: "polygon";
|
|
2616
|
+
/** @hidden */ m_centroid: Vec2Value;
|
|
2617
|
+
/** @hidden */ m_vertices: Vec2Value[];
|
|
2618
|
+
/** @hidden */ m_normals: Vec2Value[];
|
|
2619
|
+
/** @hidden */ m_count: number;
|
|
2620
|
+
/** @hidden */ m_radius: number;
|
|
2621
|
+
constructor(vertices?: Vec2Value[]);
|
|
2622
|
+
/** @hidden */
|
|
2623
|
+
_serialize(): object;
|
|
2624
|
+
/** @hidden */
|
|
2625
|
+
static _deserialize(data: any, fixture: any, restore: any): PolygonShape;
|
|
2626
|
+
getType(): "polygon";
|
|
2627
|
+
getRadius(): number;
|
|
2628
|
+
/**
|
|
2629
|
+
* Get the number of child primitives.
|
|
2630
|
+
*/
|
|
2631
|
+
getChildCount(): 1;
|
|
2632
|
+
/** @hidden */
|
|
2633
|
+
_reset(): void;
|
|
2634
|
+
/**
|
|
2635
|
+
* Test a point for containment in this shape. This only works for convex
|
|
2636
|
+
* shapes.
|
|
2637
|
+
*
|
|
2638
|
+
* @param xf The shape world transform.
|
|
2639
|
+
* @param p A point in world coordinates.
|
|
2640
|
+
*/
|
|
2641
|
+
testPoint(xf: TransformValue, p: Vec2Value): boolean;
|
|
2642
|
+
/**
|
|
2643
|
+
* Cast a ray against a child shape.
|
|
2644
|
+
*
|
|
2645
|
+
* @param output The ray-cast results.
|
|
2646
|
+
* @param input The ray-cast input parameters.
|
|
2647
|
+
* @param xf The transform to be applied to the shape.
|
|
2648
|
+
* @param childIndex The child shape index
|
|
2649
|
+
*/
|
|
2650
|
+
rayCast(output: RayCastOutput, input: RayCastInput, xf: TransformValue, childIndex: number): boolean;
|
|
2651
|
+
/**
|
|
2652
|
+
* Given a transform, compute the associated axis aligned bounding box for a
|
|
2653
|
+
* child shape.
|
|
2654
|
+
*
|
|
2655
|
+
* @param aabb Returns the axis aligned box.
|
|
2656
|
+
* @param xf The world transform of the shape.
|
|
2657
|
+
* @param childIndex The child shape
|
|
2658
|
+
*/
|
|
2659
|
+
computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;
|
|
2660
|
+
/**
|
|
2661
|
+
* Compute the mass properties of this shape using its dimensions and density.
|
|
2662
|
+
* The inertia tensor is computed about the local origin.
|
|
2663
|
+
*
|
|
2664
|
+
* @param massData Returns the mass data for this shape.
|
|
2665
|
+
* @param density The density in kilograms per meter squared.
|
|
2666
|
+
*/
|
|
2667
|
+
computeMass(massData: MassData, density: number): void;
|
|
2668
|
+
/**
|
|
2669
|
+
* Validate convexity. This is a very time consuming operation.
|
|
2670
|
+
* @returns true if valid
|
|
2671
|
+
*/
|
|
2672
|
+
validate(): boolean;
|
|
2673
|
+
computeDistanceProxy(proxy: DistanceProxy): void;
|
|
2674
|
+
}
|
|
2675
|
+
/**
|
|
2676
|
+
* A chain shape is a free form sequence of line segments. The chain has
|
|
2677
|
+
* two-sided collision, so you can use inside and outside collision. Therefore,
|
|
2678
|
+
* you may use any winding order. Connectivity information is used to create
|
|
2679
|
+
* smooth collisions.
|
|
2680
|
+
*
|
|
2681
|
+
* WARNING: The chain will not collide properly if there are self-intersections.
|
|
2682
|
+
*/
|
|
2683
|
+
export declare class ChainShape extends Shape {
|
|
2684
|
+
static TYPE: "chain";
|
|
2685
|
+
/** @hidden */ m_type: "chain";
|
|
2686
|
+
/** @hidden */ m_radius: number;
|
|
2687
|
+
/** @hidden */ m_vertices: Vec2Value[];
|
|
2688
|
+
/** @hidden */ m_count: number;
|
|
2689
|
+
/** @hidden */ m_prevVertex: Vec2Value | null;
|
|
2690
|
+
/** @hidden */ m_nextVertex: Vec2Value | null;
|
|
2691
|
+
/** @hidden */ m_hasPrevVertex: boolean;
|
|
2692
|
+
/** @hidden */ m_hasNextVertex: boolean;
|
|
2693
|
+
/** @hidden */ m_isLoop: boolean;
|
|
2694
|
+
constructor(vertices?: Vec2Value[], loop?: boolean);
|
|
2695
|
+
/** @hidden */
|
|
2696
|
+
_serialize(): object;
|
|
2697
|
+
/** @hidden */
|
|
2698
|
+
static _deserialize(data: any, fixture: any, restore: any): ChainShape;
|
|
2699
|
+
getType(): "chain";
|
|
2700
|
+
getRadius(): number;
|
|
2701
|
+
/** @hidden */
|
|
2702
|
+
_reset(): void;
|
|
2703
|
+
/**
|
|
2704
|
+
* Establish connectivity to a vertex that precedes the first vertex. Don't call
|
|
2705
|
+
* this for loops.
|
|
2706
|
+
*/
|
|
2707
|
+
setPrevVertex(prevVertex: Vec2Value): void;
|
|
2708
|
+
getPrevVertex(): Vec2Value;
|
|
2709
|
+
/**
|
|
2710
|
+
* Establish connectivity to a vertex that follows the last vertex. Don't call
|
|
2711
|
+
* this for loops.
|
|
2712
|
+
*/
|
|
2713
|
+
setNextVertex(nextVertex: Vec2Value): void;
|
|
2714
|
+
getNextVertex(): Vec2Value;
|
|
2715
|
+
/**
|
|
2716
|
+
* Get the number of child primitives.
|
|
2717
|
+
*/
|
|
2718
|
+
getChildCount(): number;
|
|
2719
|
+
getChildEdge(edge: EdgeShape, childIndex: number): void;
|
|
2720
|
+
getVertex(index: number): Vec2Value;
|
|
2721
|
+
isLoop(): boolean;
|
|
2722
|
+
/**
|
|
2723
|
+
* Test a point for containment in this shape. This only works for convex
|
|
2724
|
+
* shapes.
|
|
2725
|
+
*
|
|
2726
|
+
* This always return false.
|
|
2727
|
+
*
|
|
2728
|
+
* @param xf The shape world transform.
|
|
2729
|
+
* @param p A point in world coordinates.
|
|
2730
|
+
*/
|
|
2731
|
+
testPoint(xf: TransformValue, p: Vec2Value): false;
|
|
2732
|
+
/**
|
|
2733
|
+
* Cast a ray against a child shape.
|
|
2734
|
+
*
|
|
2735
|
+
* @param output The ray-cast results.
|
|
2736
|
+
* @param input The ray-cast input parameters.
|
|
2737
|
+
* @param xf The transform to be applied to the shape.
|
|
2738
|
+
* @param childIndex The child shape index
|
|
2739
|
+
*/
|
|
2740
|
+
rayCast(output: RayCastOutput, input: RayCastInput, xf: TransformValue, childIndex: number): boolean;
|
|
2741
|
+
/**
|
|
2742
|
+
* Given a transform, compute the associated axis aligned bounding box for a
|
|
2743
|
+
* child shape.
|
|
2744
|
+
*
|
|
2745
|
+
* @param aabb Returns the axis aligned box.
|
|
2746
|
+
* @param xf The world transform of the shape.
|
|
2747
|
+
* @param childIndex The child shape
|
|
2748
|
+
*/
|
|
2749
|
+
computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;
|
|
2750
|
+
/**
|
|
2751
|
+
* Compute the mass properties of this shape using its dimensions and density.
|
|
2752
|
+
* The inertia tensor is computed about the local origin.
|
|
2753
|
+
*
|
|
2754
|
+
* Chains have zero mass.
|
|
2755
|
+
*
|
|
2756
|
+
* @param massData Returns the mass data for this shape.
|
|
2757
|
+
* @param density The density in kilograms per meter squared.
|
|
2758
|
+
*/
|
|
2759
|
+
computeMass(massData: MassData, density?: number): void;
|
|
2760
|
+
computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;
|
|
2761
|
+
}
|
|
2762
|
+
/**
|
|
2763
|
+
* A rectangle polygon which extend PolygonShape.
|
|
2764
|
+
*/
|
|
2765
|
+
export declare class BoxShape extends PolygonShape {
|
|
2766
|
+
static TYPE: "polygon";
|
|
2767
|
+
/**
|
|
2768
|
+
*
|
|
2769
|
+
* @param halfWidth
|
|
2770
|
+
* @param halfHeight
|
|
2771
|
+
* @param center coordinate of the center of the box relative to the body
|
|
2772
|
+
* @param angle angle of the box relative to the body
|
|
2773
|
+
*/
|
|
2774
|
+
constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number);
|
|
2775
|
+
}
|
|
2776
|
+
export declare const CollideCircles: (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue) => void;
|
|
2777
|
+
export declare const CollideEdgeCircle: (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue) => void;
|
|
2778
|
+
/**
|
|
2779
|
+
*
|
|
2780
|
+
* Find edge normal of max separation on A - return if separating axis is found
|
|
2781
|
+
* Find edge normal of max separation on B - return if separation axis is found
|
|
2782
|
+
* Choose reference edge as min(minA, minB)
|
|
2783
|
+
* Find incident edge
|
|
2784
|
+
* Clip
|
|
2785
|
+
*
|
|
2786
|
+
* The normal points from 1 to 2
|
|
2787
|
+
*/
|
|
2788
|
+
export declare const CollidePolygons: (manifold: Manifold, polyA: PolygonShape, xfA: TransformValue, polyB: PolygonShape, xfB: TransformValue) => void;
|
|
2789
|
+
export declare const CollidePolygonCircle: (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue) => void;
|
|
2790
|
+
/**
|
|
2791
|
+
* This function collides and edge and a polygon, taking into account edge
|
|
2792
|
+
* adjacency.
|
|
2793
|
+
*/
|
|
2794
|
+
export declare const CollideEdgePolygon: (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue) => void;
|
|
2795
|
+
/**
|
|
2796
|
+
* Distance joint definition. This requires defining an anchor point on both
|
|
2797
|
+
* bodies and the non-zero length of the distance joint. The definition uses
|
|
2798
|
+
* local anchor points so that the initial configuration can violate the
|
|
2799
|
+
* constraint slightly. This helps when saving and loading a game. Warning: Do
|
|
2800
|
+
* not use a zero or short length.
|
|
2801
|
+
*/
|
|
2802
|
+
export interface DistanceJointOpt extends JointOpt {
|
|
2803
|
+
/**
|
|
2804
|
+
* The mass-spring-damper frequency in Hertz. A value of 0 disables softness.
|
|
2805
|
+
*/
|
|
2806
|
+
frequencyHz?: number;
|
|
2807
|
+
/**
|
|
2808
|
+
* The damping ratio. 0 = no damping, 1 = critical damping.
|
|
2809
|
+
*/
|
|
2810
|
+
dampingRatio?: number;
|
|
2811
|
+
/**
|
|
2812
|
+
* Distance length.
|
|
2813
|
+
*/
|
|
2814
|
+
length?: number;
|
|
2815
|
+
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Distance joint definition. This requires defining an anchor point on both
|
|
2818
|
+
* bodies and the non-zero length of the distance joint. The definition uses
|
|
2819
|
+
* local anchor points so that the initial configuration can violate the
|
|
2820
|
+
* constraint slightly. This helps when saving and loading a game. Warning: Do
|
|
2821
|
+
* not use a zero or short length.
|
|
2822
|
+
*/
|
|
2823
|
+
export interface DistanceJointDef extends JointDef, DistanceJointOpt {
|
|
2824
|
+
/**
|
|
2825
|
+
* The local anchor point relative to bodyA's origin.
|
|
2826
|
+
*/
|
|
2827
|
+
localAnchorA: Vec2Value;
|
|
2828
|
+
/**
|
|
2829
|
+
* The local anchor point relative to bodyB's origin.
|
|
2830
|
+
*/
|
|
2831
|
+
localAnchorB: Vec2Value;
|
|
2832
|
+
}
|
|
2833
|
+
/**
|
|
2834
|
+
* A distance joint constrains two points on two bodies to remain at a fixed
|
|
2835
|
+
* distance from each other. You can view this as a massless, rigid rod.
|
|
2836
|
+
*/
|
|
2837
|
+
export declare class DistanceJoint extends Joint {
|
|
2838
|
+
static TYPE: "distance-joint";
|
|
2839
|
+
/**
|
|
2840
|
+
* @param def DistanceJoint definition.
|
|
2841
|
+
*/
|
|
2842
|
+
constructor(def: DistanceJointDef);
|
|
2843
|
+
/**
|
|
2844
|
+
* @param anchorA Anchor A in global coordination.
|
|
2845
|
+
* @param anchorB Anchor B in global coordination.
|
|
2846
|
+
*/
|
|
2847
|
+
constructor(def: DistanceJointOpt, bodyA: Body$1, bodyB: Body$1, anchorA?: Vec2Value, anchorB?: Vec2Value);
|
|
2848
|
+
/** @hidden */
|
|
2849
|
+
_serialize(): object;
|
|
2850
|
+
/** @hidden */
|
|
2851
|
+
static _deserialize(data: any, world: any, restore: any): DistanceJoint;
|
|
2852
|
+
/** @hidden */
|
|
2853
|
+
_reset(def: Partial<DistanceJointDef>): void;
|
|
2854
|
+
/**
|
|
2855
|
+
* The local anchor point relative to bodyA's origin.
|
|
2856
|
+
*/
|
|
2857
|
+
getLocalAnchorA(): Vec2Value;
|
|
2858
|
+
/**
|
|
2859
|
+
* The local anchor point relative to bodyB's origin.
|
|
2860
|
+
*/
|
|
2861
|
+
getLocalAnchorB(): Vec2Value;
|
|
2862
|
+
/**
|
|
2863
|
+
* Set the natural length. Manipulating the length can lead to non-physical
|
|
2864
|
+
* behavior when the frequency is zero.
|
|
2865
|
+
*/
|
|
2866
|
+
setLength(length: number): void;
|
|
2867
|
+
/**
|
|
2868
|
+
* Get the natural length.
|
|
2869
|
+
*/
|
|
2870
|
+
getLength(): number;
|
|
2871
|
+
setFrequency(hz: number): void;
|
|
2872
|
+
getFrequency(): number;
|
|
2873
|
+
setDampingRatio(ratio: number): void;
|
|
2874
|
+
getDampingRatio(): number;
|
|
2875
|
+
/**
|
|
2876
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
2877
|
+
*/
|
|
2878
|
+
getAnchorA(): Vec2Value;
|
|
2879
|
+
/**
|
|
2880
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
2881
|
+
*/
|
|
2882
|
+
getAnchorB(): Vec2Value;
|
|
2883
|
+
/**
|
|
2884
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
2885
|
+
*/
|
|
2886
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
2887
|
+
/**
|
|
2888
|
+
* Get the reaction torque on bodyB in N*m.
|
|
2889
|
+
*/
|
|
2890
|
+
getReactionTorque(inv_dt: number): number;
|
|
2891
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
2892
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
2893
|
+
/**
|
|
2894
|
+
* This returns true if the position errors are within tolerance.
|
|
2895
|
+
*/
|
|
2896
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Friction joint definition.
|
|
2900
|
+
*/
|
|
2901
|
+
export interface FrictionJointOpt extends JointOpt {
|
|
2902
|
+
/**
|
|
2903
|
+
* The maximum friction force in N.
|
|
2904
|
+
*/
|
|
2905
|
+
maxForce?: number;
|
|
2906
|
+
/**
|
|
2907
|
+
* The maximum friction torque in N-m.
|
|
2908
|
+
*/
|
|
2909
|
+
maxTorque?: number;
|
|
2910
|
+
}
|
|
2911
|
+
/**
|
|
2912
|
+
* Friction joint definition.
|
|
2913
|
+
*/
|
|
2914
|
+
export interface FrictionJointDef extends JointDef, FrictionJointOpt {
|
|
2915
|
+
/**
|
|
2916
|
+
* The local anchor point relative to bodyA's origin.
|
|
2917
|
+
*/
|
|
2918
|
+
localAnchorA: Vec2Value;
|
|
2919
|
+
/**
|
|
2920
|
+
* The local anchor point relative to bodyB's origin.
|
|
2921
|
+
*/
|
|
2922
|
+
localAnchorB: Vec2Value;
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2925
|
+
* Friction joint. This is used for top-down friction. It provides 2D
|
|
2926
|
+
* translational friction and angular friction.
|
|
2927
|
+
*/
|
|
2928
|
+
export declare class FrictionJoint extends Joint {
|
|
2929
|
+
static TYPE: "friction-joint";
|
|
2930
|
+
constructor(def: FrictionJointDef);
|
|
2931
|
+
/**
|
|
2932
|
+
* @param anchor Anchor in global coordination.
|
|
2933
|
+
*/
|
|
2934
|
+
constructor(def: FrictionJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
|
|
2935
|
+
/** @hidden */
|
|
2936
|
+
_serialize(): object;
|
|
2937
|
+
/** @hidden */
|
|
2938
|
+
static _deserialize(data: any, world: any, restore: any): FrictionJoint;
|
|
2939
|
+
/** @hidden */
|
|
2940
|
+
_reset(def: Partial<FrictionJointDef>): void;
|
|
2941
|
+
/**
|
|
2942
|
+
* The local anchor point relative to bodyA's origin.
|
|
2943
|
+
*/
|
|
2944
|
+
getLocalAnchorA(): Vec2Value;
|
|
2945
|
+
/**
|
|
2946
|
+
* The local anchor point relative to bodyB's origin.
|
|
2947
|
+
*/
|
|
2948
|
+
getLocalAnchorB(): Vec2Value;
|
|
2949
|
+
/**
|
|
2950
|
+
* Set the maximum friction force in N.
|
|
2951
|
+
*/
|
|
2952
|
+
setMaxForce(force: number): void;
|
|
2953
|
+
/**
|
|
2954
|
+
* Get the maximum friction force in N.
|
|
2955
|
+
*/
|
|
2956
|
+
getMaxForce(): number;
|
|
2957
|
+
/**
|
|
2958
|
+
* Set the maximum friction torque in N*m.
|
|
2959
|
+
*/
|
|
2960
|
+
setMaxTorque(torque: number): void;
|
|
2961
|
+
/**
|
|
2962
|
+
* Get the maximum friction torque in N*m.
|
|
2963
|
+
*/
|
|
2964
|
+
getMaxTorque(): number;
|
|
2965
|
+
/**
|
|
2966
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
2967
|
+
*/
|
|
2968
|
+
getAnchorA(): Vec2Value;
|
|
2969
|
+
/**
|
|
2970
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
2971
|
+
*/
|
|
2972
|
+
getAnchorB(): Vec2Value;
|
|
2973
|
+
/**
|
|
2974
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
2975
|
+
*/
|
|
2976
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
2977
|
+
/**
|
|
2978
|
+
* Get the reaction torque on bodyB in N*m.
|
|
2979
|
+
*/
|
|
2980
|
+
getReactionTorque(inv_dt: number): number;
|
|
2981
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
2982
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
2983
|
+
/**
|
|
2984
|
+
* This returns true if the position errors are within tolerance.
|
|
2985
|
+
*/
|
|
2986
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Revolute joint definition. This requires defining an anchor point where the
|
|
2990
|
+
* bodies are joined. The definition uses local anchor points so that the
|
|
2991
|
+
* initial configuration can violate the constraint slightly. You also need to
|
|
2992
|
+
* specify the initial relative angle for joint limits. This helps when saving
|
|
2993
|
+
* and loading a game.
|
|
2994
|
+
*
|
|
2995
|
+
* The local anchor points are measured from the body's origin rather than the
|
|
2996
|
+
* center of mass because: 1. you might not know where the center of mass will
|
|
2997
|
+
* be. 2. if you add/remove shapes from a body and recompute the mass, the
|
|
2998
|
+
* joints will be broken.
|
|
2999
|
+
*/
|
|
3000
|
+
export interface RevoluteJointOpt extends JointOpt {
|
|
3001
|
+
/**
|
|
3002
|
+
* The lower angle for the joint limit (radians).
|
|
3003
|
+
*/
|
|
3004
|
+
lowerAngle?: number;
|
|
3005
|
+
/**
|
|
3006
|
+
* The upper angle for the joint limit (radians).
|
|
3007
|
+
*/
|
|
3008
|
+
upperAngle?: number;
|
|
3009
|
+
/**
|
|
3010
|
+
* The maximum motor torque used to achieve the desired motor speed. Usually
|
|
3011
|
+
* in N-m.
|
|
3012
|
+
*/
|
|
3013
|
+
maxMotorTorque?: number;
|
|
3014
|
+
/**
|
|
3015
|
+
* The desired motor speed. Usually in radians per second.
|
|
3016
|
+
*/
|
|
3017
|
+
motorSpeed?: number;
|
|
3018
|
+
/**
|
|
3019
|
+
* A flag to enable joint limits.
|
|
3020
|
+
*/
|
|
3021
|
+
enableLimit?: boolean;
|
|
3022
|
+
/**
|
|
3023
|
+
* A flag to enable the joint motor.
|
|
3024
|
+
*/
|
|
3025
|
+
enableMotor?: boolean;
|
|
3026
|
+
}
|
|
3027
|
+
/**
|
|
3028
|
+
* Revolute joint definition. This requires defining an anchor point where the
|
|
3029
|
+
* bodies are joined. The definition uses local anchor points so that the
|
|
3030
|
+
* initial configuration can violate the constraint slightly. You also need to
|
|
3031
|
+
* specify the initial relative angle for joint limits. This helps when saving
|
|
3032
|
+
* and loading a game.
|
|
3033
|
+
*
|
|
3034
|
+
* The local anchor points are measured from the body's origin rather than the
|
|
3035
|
+
* center of mass because: 1. you might not know where the center of mass will
|
|
3036
|
+
* be. 2. if you add/remove shapes from a body and recompute the mass, the
|
|
3037
|
+
* joints will be broken.
|
|
3038
|
+
*/
|
|
3039
|
+
export interface RevoluteJointDef extends JointDef, RevoluteJointOpt {
|
|
3040
|
+
/**
|
|
3041
|
+
* The local anchor point relative to bodyA's origin.
|
|
3042
|
+
*/
|
|
3043
|
+
localAnchorA: Vec2Value;
|
|
3044
|
+
/**
|
|
3045
|
+
* The local anchor point relative to bodyB's origin.
|
|
3046
|
+
*/
|
|
3047
|
+
localAnchorB: Vec2Value;
|
|
3048
|
+
/**
|
|
3049
|
+
* The bodyB angle minus bodyA angle in the reference state (radians).
|
|
3050
|
+
*/
|
|
3051
|
+
referenceAngle?: number;
|
|
3052
|
+
}
|
|
3053
|
+
/**
|
|
3054
|
+
* A revolute joint constrains two bodies to share a common point while they are
|
|
3055
|
+
* free to rotate about the point. The relative rotation about the shared point
|
|
3056
|
+
* is the joint angle. You can limit the relative rotation with a joint limit
|
|
3057
|
+
* that specifies a lower and upper angle. You can use a motor to drive the
|
|
3058
|
+
* relative rotation about the shared point. A maximum motor torque is provided
|
|
3059
|
+
* so that infinite forces are not generated.
|
|
3060
|
+
*/
|
|
3061
|
+
export declare class RevoluteJoint extends Joint {
|
|
3062
|
+
static TYPE: "revolute-joint";
|
|
3063
|
+
constructor(def: RevoluteJointDef);
|
|
3064
|
+
constructor(def: RevoluteJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
|
|
3065
|
+
/** @hidden */
|
|
3066
|
+
_serialize(): object;
|
|
3067
|
+
/** @hidden */
|
|
3068
|
+
static _deserialize(data: any, world: any, restore: any): RevoluteJoint;
|
|
3069
|
+
/** @hidden */
|
|
3070
|
+
_reset(def: Partial<RevoluteJointDef>): void;
|
|
3071
|
+
/**
|
|
3072
|
+
* The local anchor point relative to bodyA's origin.
|
|
3073
|
+
*/
|
|
3074
|
+
getLocalAnchorA(): Vec2Value;
|
|
3075
|
+
/**
|
|
3076
|
+
* The local anchor point relative to bodyB's origin.
|
|
3077
|
+
*/
|
|
3078
|
+
getLocalAnchorB(): Vec2Value;
|
|
3079
|
+
/**
|
|
3080
|
+
* Get the reference angle.
|
|
3081
|
+
*/
|
|
3082
|
+
getReferenceAngle(): number;
|
|
3083
|
+
/**
|
|
3084
|
+
* Get the current joint angle in radians.
|
|
3085
|
+
*/
|
|
3086
|
+
getJointAngle(): number;
|
|
3087
|
+
/**
|
|
3088
|
+
* Get the current joint angle speed in radians per second.
|
|
3089
|
+
*/
|
|
3090
|
+
getJointSpeed(): number;
|
|
3091
|
+
/**
|
|
3092
|
+
* Is the joint motor enabled?
|
|
3093
|
+
*/
|
|
3094
|
+
isMotorEnabled(): boolean;
|
|
3095
|
+
/**
|
|
3096
|
+
* Enable/disable the joint motor.
|
|
3097
|
+
*/
|
|
3098
|
+
enableMotor(flag: boolean): void;
|
|
3099
|
+
/**
|
|
3100
|
+
* Get the current motor torque given the inverse time step. Unit is N*m.
|
|
3101
|
+
*/
|
|
3102
|
+
getMotorTorque(inv_dt: number): number;
|
|
3103
|
+
/**
|
|
3104
|
+
* Set the motor speed in radians per second.
|
|
3105
|
+
*/
|
|
3106
|
+
setMotorSpeed(speed: number): void;
|
|
3107
|
+
/**
|
|
3108
|
+
* Get the motor speed in radians per second.
|
|
3109
|
+
*/
|
|
3110
|
+
getMotorSpeed(): number;
|
|
3111
|
+
/**
|
|
3112
|
+
* Set the maximum motor torque, usually in N-m.
|
|
3113
|
+
*/
|
|
3114
|
+
setMaxMotorTorque(torque: number): void;
|
|
3115
|
+
getMaxMotorTorque(): number;
|
|
3116
|
+
/**
|
|
3117
|
+
* Is the joint limit enabled?
|
|
3118
|
+
*/
|
|
3119
|
+
isLimitEnabled(): boolean;
|
|
3120
|
+
/**
|
|
3121
|
+
* Enable/disable the joint limit.
|
|
3122
|
+
*/
|
|
3123
|
+
enableLimit(flag: boolean): void;
|
|
3124
|
+
/**
|
|
3125
|
+
* Get the lower joint limit in radians.
|
|
3126
|
+
*/
|
|
3127
|
+
getLowerLimit(): number;
|
|
3128
|
+
/**
|
|
3129
|
+
* Get the upper joint limit in radians.
|
|
3130
|
+
*/
|
|
3131
|
+
getUpperLimit(): number;
|
|
3132
|
+
/**
|
|
3133
|
+
* Set the joint limits in radians.
|
|
3134
|
+
*/
|
|
3135
|
+
setLimits(lower: number, upper: number): void;
|
|
3136
|
+
/**
|
|
3137
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3138
|
+
*/
|
|
3139
|
+
getAnchorA(): Vec2Value;
|
|
3140
|
+
/**
|
|
3141
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3142
|
+
*/
|
|
3143
|
+
getAnchorB(): Vec2Value;
|
|
3144
|
+
/**
|
|
3145
|
+
* Get the reaction force given the inverse time step. Unit is N.
|
|
3146
|
+
*/
|
|
3147
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3148
|
+
/**
|
|
3149
|
+
* Get the reaction torque due to the joint limit given the inverse time step.
|
|
3150
|
+
* Unit is N*m.
|
|
3151
|
+
*/
|
|
3152
|
+
getReactionTorque(inv_dt: number): number;
|
|
3153
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3154
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3155
|
+
/**
|
|
3156
|
+
* This returns true if the position errors are within tolerance.
|
|
3157
|
+
*/
|
|
3158
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3159
|
+
}
|
|
3160
|
+
/**
|
|
3161
|
+
* Prismatic joint definition. This requires defining a line of motion using an
|
|
3162
|
+
* axis and an anchor point. The definition uses local anchor points and a local
|
|
3163
|
+
* axis so that the initial configuration can violate the constraint slightly.
|
|
3164
|
+
* The joint translation is zero when the local anchor points coincide in world
|
|
3165
|
+
* space. Using local anchors and a local axis helps when saving and loading a
|
|
3166
|
+
* game.
|
|
3167
|
+
*/
|
|
3168
|
+
export interface PrismaticJointOpt extends JointOpt {
|
|
3169
|
+
/**
|
|
3170
|
+
* Enable/disable the joint limit.
|
|
3171
|
+
*/
|
|
3172
|
+
enableLimit?: boolean;
|
|
3173
|
+
/**
|
|
3174
|
+
* The lower translation limit, usually in meters.
|
|
3175
|
+
*/
|
|
3176
|
+
lowerTranslation?: number;
|
|
3177
|
+
/**
|
|
3178
|
+
* The upper translation limit, usually in meters.
|
|
3179
|
+
*/
|
|
3180
|
+
upperTranslation?: number;
|
|
3181
|
+
/**
|
|
3182
|
+
* Enable/disable the joint motor.
|
|
3183
|
+
*/
|
|
3184
|
+
enableMotor?: boolean;
|
|
3185
|
+
/**
|
|
3186
|
+
* The maximum motor torque, usually in N-m.
|
|
3187
|
+
*/
|
|
3188
|
+
maxMotorForce?: number;
|
|
3189
|
+
/**
|
|
3190
|
+
* The desired motor speed in radians per second.
|
|
3191
|
+
*/
|
|
3192
|
+
motorSpeed?: number;
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Prismatic joint definition. This requires defining a line of motion using an
|
|
3196
|
+
* axis and an anchor point. The definition uses local anchor points and a local
|
|
3197
|
+
* axis so that the initial configuration can violate the constraint slightly.
|
|
3198
|
+
* The joint translation is zero when the local anchor points coincide in world
|
|
3199
|
+
* space. Using local anchors and a local axis helps when saving and loading a
|
|
3200
|
+
* game.
|
|
3201
|
+
*/
|
|
3202
|
+
export interface PrismaticJointDef extends JointDef, PrismaticJointOpt {
|
|
3203
|
+
/**
|
|
3204
|
+
* The local anchor point relative to bodyA's origin.
|
|
3205
|
+
*/
|
|
3206
|
+
localAnchorA: Vec2Value;
|
|
3207
|
+
/**
|
|
3208
|
+
* The local anchor point relative to bodyB's origin.
|
|
3209
|
+
*/
|
|
3210
|
+
localAnchorB: Vec2Value;
|
|
3211
|
+
/**
|
|
3212
|
+
* The local translation unit axis in bodyA.
|
|
3213
|
+
*/
|
|
3214
|
+
localAxisA: Vec2Value;
|
|
3215
|
+
/**
|
|
3216
|
+
* referenceAngle The constrained angle between the bodies:
|
|
3217
|
+
* bodyB_angle - bodyA_angle.
|
|
3218
|
+
*/
|
|
3219
|
+
referenceAngle?: number;
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* A prismatic joint. This joint provides one degree of freedom: translation
|
|
3223
|
+
* along an axis fixed in bodyA. Relative rotation is prevented. You can use a
|
|
3224
|
+
* joint limit to restrict the range of motion and a joint motor to drive the
|
|
3225
|
+
* motion or to model joint friction.
|
|
3226
|
+
*/
|
|
3227
|
+
export declare class PrismaticJoint extends Joint {
|
|
3228
|
+
static TYPE: "prismatic-joint";
|
|
3229
|
+
constructor(def: PrismaticJointDef);
|
|
3230
|
+
constructor(def: PrismaticJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value, axis?: Vec2Value);
|
|
3231
|
+
/** @hidden */
|
|
3232
|
+
_serialize(): object;
|
|
3233
|
+
/** @hidden */
|
|
3234
|
+
static _deserialize(data: any, world: any, restore: any): PrismaticJoint;
|
|
3235
|
+
/** @hidden */
|
|
3236
|
+
_reset(def: Partial<PrismaticJointDef>): void;
|
|
3237
|
+
/**
|
|
3238
|
+
* The local anchor point relative to bodyA's origin.
|
|
3239
|
+
*/
|
|
3240
|
+
getLocalAnchorA(): Vec2Value;
|
|
3241
|
+
/**
|
|
3242
|
+
* The local anchor point relative to bodyB's origin.
|
|
3243
|
+
*/
|
|
3244
|
+
getLocalAnchorB(): Vec2Value;
|
|
3245
|
+
/**
|
|
3246
|
+
* The local joint axis relative to bodyA.
|
|
3247
|
+
*/
|
|
3248
|
+
getLocalAxisA(): Vec2Value;
|
|
3249
|
+
/**
|
|
3250
|
+
* Get the reference angle.
|
|
3251
|
+
*/
|
|
3252
|
+
getReferenceAngle(): number;
|
|
3253
|
+
/**
|
|
3254
|
+
* Get the current joint translation, usually in meters.
|
|
3255
|
+
*/
|
|
3256
|
+
getJointTranslation(): number;
|
|
3257
|
+
/**
|
|
3258
|
+
* Get the current joint translation speed, usually in meters per second.
|
|
3259
|
+
*/
|
|
3260
|
+
getJointSpeed(): number;
|
|
3261
|
+
/**
|
|
3262
|
+
* Is the joint limit enabled?
|
|
3263
|
+
*/
|
|
3264
|
+
isLimitEnabled(): boolean;
|
|
3265
|
+
/**
|
|
3266
|
+
* Enable/disable the joint limit.
|
|
3267
|
+
*/
|
|
3268
|
+
enableLimit(flag: boolean): void;
|
|
3269
|
+
/**
|
|
3270
|
+
* Get the lower joint limit, usually in meters.
|
|
3271
|
+
*/
|
|
3272
|
+
getLowerLimit(): number;
|
|
3273
|
+
/**
|
|
3274
|
+
* Get the upper joint limit, usually in meters.
|
|
3275
|
+
*/
|
|
3276
|
+
getUpperLimit(): number;
|
|
3277
|
+
/**
|
|
3278
|
+
* Set the joint limits, usually in meters.
|
|
3279
|
+
*/
|
|
3280
|
+
setLimits(lower: number, upper: number): void;
|
|
3281
|
+
/**
|
|
3282
|
+
* Is the joint motor enabled?
|
|
3283
|
+
*/
|
|
3284
|
+
isMotorEnabled(): boolean;
|
|
3285
|
+
/**
|
|
3286
|
+
* Enable/disable the joint motor.
|
|
3287
|
+
*/
|
|
3288
|
+
enableMotor(flag: boolean): void;
|
|
3289
|
+
/**
|
|
3290
|
+
* Set the motor speed, usually in meters per second.
|
|
3291
|
+
*/
|
|
3292
|
+
setMotorSpeed(speed: number): void;
|
|
3293
|
+
/**
|
|
3294
|
+
* Set the maximum motor force, usually in N.
|
|
3295
|
+
*/
|
|
3296
|
+
setMaxMotorForce(force: number): void;
|
|
3297
|
+
getMaxMotorForce(): number;
|
|
3298
|
+
/**
|
|
3299
|
+
* Get the motor speed, usually in meters per second.
|
|
3300
|
+
*/
|
|
3301
|
+
getMotorSpeed(): number;
|
|
3302
|
+
/**
|
|
3303
|
+
* Get the current motor force given the inverse time step, usually in N.
|
|
3304
|
+
*/
|
|
3305
|
+
getMotorForce(inv_dt: number): number;
|
|
3306
|
+
/**
|
|
3307
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3308
|
+
*/
|
|
3309
|
+
getAnchorA(): Vec2Value;
|
|
3310
|
+
/**
|
|
3311
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3312
|
+
*/
|
|
3313
|
+
getAnchorB(): Vec2Value;
|
|
3314
|
+
/**
|
|
3315
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3316
|
+
*/
|
|
3317
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3318
|
+
/**
|
|
3319
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3320
|
+
*/
|
|
3321
|
+
getReactionTorque(inv_dt: number): number;
|
|
3322
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3323
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3324
|
+
/**
|
|
3325
|
+
* This returns true if the position errors are within tolerance.
|
|
3326
|
+
*/
|
|
3327
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3328
|
+
}
|
|
3329
|
+
/**
|
|
3330
|
+
* Gear joint definition.
|
|
3331
|
+
*/
|
|
3332
|
+
export interface GearJointOpt extends JointOpt {
|
|
3333
|
+
/**
|
|
3334
|
+
* The gear ratio. See {@link GearJoint} for explanation.
|
|
3335
|
+
*/
|
|
3336
|
+
ratio?: number;
|
|
3337
|
+
}
|
|
3338
|
+
/**
|
|
3339
|
+
* Gear joint definition.
|
|
3340
|
+
*/
|
|
3341
|
+
export interface GearJointDef extends JointDef, GearJointOpt {
|
|
3342
|
+
/**
|
|
3343
|
+
* The first revolute/prismatic joint attached to the gear joint.
|
|
3344
|
+
*/
|
|
3345
|
+
joint1: RevoluteJoint | PrismaticJoint;
|
|
3346
|
+
/**
|
|
3347
|
+
* The second prismatic/revolute joint attached to the gear joint.
|
|
3348
|
+
*/
|
|
3349
|
+
joint2: RevoluteJoint | PrismaticJoint;
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* A gear joint is used to connect two joints together. Either joint can be a
|
|
3353
|
+
* revolute or prismatic joint. You specify a gear ratio to bind the motions
|
|
3354
|
+
* together: coordinate1 + ratio * coordinate2 = constant
|
|
3355
|
+
*
|
|
3356
|
+
* The ratio can be negative or positive. If one joint is a revolute joint and
|
|
3357
|
+
* the other joint is a prismatic joint, then the ratio will have units of
|
|
3358
|
+
* length or units of 1/length. Warning: You have to manually destroy the gear
|
|
3359
|
+
* joint if joint1 or joint2 is destroyed.
|
|
3360
|
+
*
|
|
3361
|
+
* This definition requires two existing revolute or prismatic joints (any
|
|
3362
|
+
* combination will work).
|
|
3363
|
+
*/
|
|
3364
|
+
export declare class GearJoint extends Joint {
|
|
3365
|
+
static TYPE: "gear-joint";
|
|
3366
|
+
constructor(def: GearJointDef);
|
|
3367
|
+
constructor(def: GearJointOpt, bodyA: Body$1, bodyB: Body$1, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);
|
|
3368
|
+
/** @hidden */
|
|
3369
|
+
_serialize(): object;
|
|
3370
|
+
/** @hidden */
|
|
3371
|
+
static _deserialize(data: any, world: any, restore: any): GearJoint;
|
|
3372
|
+
/** @hidden */
|
|
3373
|
+
_reset(def: Partial<GearJointDef>): void;
|
|
3374
|
+
/**
|
|
3375
|
+
* Get the first joint.
|
|
3376
|
+
*/
|
|
3377
|
+
getJoint1(): Joint;
|
|
3378
|
+
/**
|
|
3379
|
+
* Get the second joint.
|
|
3380
|
+
*/
|
|
3381
|
+
getJoint2(): Joint;
|
|
3382
|
+
/**
|
|
3383
|
+
* Set the gear ratio.
|
|
3384
|
+
*/
|
|
3385
|
+
setRatio(ratio: number): void;
|
|
3386
|
+
/**
|
|
3387
|
+
* Get the gear ratio.
|
|
3388
|
+
*/
|
|
3389
|
+
getRatio(): number;
|
|
3390
|
+
/**
|
|
3391
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3392
|
+
*/
|
|
3393
|
+
getAnchorA(): Vec2Value;
|
|
3394
|
+
/**
|
|
3395
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3396
|
+
*/
|
|
3397
|
+
getAnchorB(): Vec2Value;
|
|
3398
|
+
/**
|
|
3399
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3400
|
+
*/
|
|
3401
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3402
|
+
/**
|
|
3403
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3404
|
+
*/
|
|
3405
|
+
getReactionTorque(inv_dt: number): number;
|
|
3406
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3407
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3408
|
+
/**
|
|
3409
|
+
* This returns true if the position errors are within tolerance.
|
|
3410
|
+
*/
|
|
3411
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3412
|
+
}
|
|
3413
|
+
/**
|
|
3414
|
+
* Motor joint definition.
|
|
3415
|
+
*/
|
|
3416
|
+
export interface MotorJointOpt extends JointOpt {
|
|
3417
|
+
/**
|
|
3418
|
+
* The bodyB angle minus bodyA angle in radians.
|
|
3419
|
+
*/
|
|
3420
|
+
angularOffset?: number;
|
|
3421
|
+
/**
|
|
3422
|
+
* The maximum motor force in N.
|
|
3423
|
+
*/
|
|
3424
|
+
maxForce?: number;
|
|
3425
|
+
/**
|
|
3426
|
+
* The maximum motor torque in N-m.
|
|
3427
|
+
*/
|
|
3428
|
+
maxTorque?: number;
|
|
3429
|
+
/**
|
|
3430
|
+
* Position correction factor in the range [0,1].
|
|
3431
|
+
*/
|
|
3432
|
+
correctionFactor?: number;
|
|
3433
|
+
/**
|
|
3434
|
+
* Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.
|
|
3435
|
+
*/
|
|
3436
|
+
linearOffset?: Vec2Value;
|
|
3437
|
+
}
|
|
3438
|
+
/**
|
|
3439
|
+
* Motor joint definition.
|
|
3440
|
+
*/
|
|
3441
|
+
export interface MotorJointDef extends JointDef, MotorJointOpt {
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* A motor joint is used to control the relative motion between two bodies. A
|
|
3445
|
+
* typical usage is to control the movement of a dynamic body with respect to
|
|
3446
|
+
* the ground.
|
|
3447
|
+
*/
|
|
3448
|
+
export declare class MotorJoint extends Joint {
|
|
3449
|
+
static TYPE: "motor-joint";
|
|
3450
|
+
constructor(def: MotorJointDef);
|
|
3451
|
+
constructor(def: MotorJointOpt, bodyA: Body$1, bodyB: Body$1);
|
|
3452
|
+
/** @hidden */
|
|
3453
|
+
_serialize(): object;
|
|
3454
|
+
/** @hidden */
|
|
3455
|
+
static _deserialize(data: any, world: any, restore: any): MotorJoint;
|
|
3456
|
+
/** @hidden */
|
|
3457
|
+
_reset(def: Partial<MotorJointDef>): void;
|
|
3458
|
+
/**
|
|
3459
|
+
* Set the maximum friction force in N.
|
|
3460
|
+
*/
|
|
3461
|
+
setMaxForce(force: number): void;
|
|
3462
|
+
/**
|
|
3463
|
+
* Get the maximum friction force in N.
|
|
3464
|
+
*/
|
|
3465
|
+
getMaxForce(): number;
|
|
3466
|
+
/**
|
|
3467
|
+
* Set the maximum friction torque in N*m.
|
|
3468
|
+
*/
|
|
3469
|
+
setMaxTorque(torque: number): void;
|
|
3470
|
+
/**
|
|
3471
|
+
* Get the maximum friction torque in N*m.
|
|
3472
|
+
*/
|
|
3473
|
+
getMaxTorque(): number;
|
|
3474
|
+
/**
|
|
3475
|
+
* Set the position correction factor in the range [0,1].
|
|
3476
|
+
*/
|
|
3477
|
+
setCorrectionFactor(factor: number): void;
|
|
3478
|
+
/**
|
|
3479
|
+
* Get the position correction factor in the range [0,1].
|
|
3480
|
+
*/
|
|
3481
|
+
getCorrectionFactor(): number;
|
|
3482
|
+
/**
|
|
3483
|
+
* Set/get the target linear offset, in frame A, in meters.
|
|
3484
|
+
*/
|
|
3485
|
+
setLinearOffset(linearOffset: Vec2Value): void;
|
|
3486
|
+
getLinearOffset(): Vec2Value;
|
|
3487
|
+
/**
|
|
3488
|
+
* Set/get the target angular offset, in radians.
|
|
3489
|
+
*/
|
|
3490
|
+
setAngularOffset(angularOffset: number): void;
|
|
3491
|
+
getAngularOffset(): number;
|
|
3492
|
+
/**
|
|
3493
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3494
|
+
*/
|
|
3495
|
+
getAnchorA(): Vec2Value;
|
|
3496
|
+
/**
|
|
3497
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3498
|
+
*/
|
|
3499
|
+
getAnchorB(): Vec2Value;
|
|
3500
|
+
/**
|
|
3501
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3502
|
+
*/
|
|
3503
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3504
|
+
/**
|
|
3505
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3506
|
+
*/
|
|
3507
|
+
getReactionTorque(inv_dt: number): number;
|
|
3508
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3509
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3510
|
+
/**
|
|
3511
|
+
* This returns true if the position errors are within tolerance.
|
|
3512
|
+
*/
|
|
3513
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3514
|
+
}
|
|
3515
|
+
/**
|
|
3516
|
+
* Mouse joint definition. This requires a world target point, tuning
|
|
3517
|
+
* parameters, and the time step.
|
|
3518
|
+
*/
|
|
3519
|
+
export interface MouseJointOpt extends JointOpt {
|
|
3520
|
+
/**
|
|
3521
|
+
* [maxForce = 0.0] The maximum constraint force that can be exerted to move
|
|
3522
|
+
* the candidate body. Usually you will express as some multiple of the
|
|
3523
|
+
* weight (multiplier * mass * gravity).
|
|
3524
|
+
*/
|
|
3525
|
+
maxForce?: number;
|
|
3526
|
+
/**
|
|
3527
|
+
* [frequencyHz = 5.0] The response speed.
|
|
3528
|
+
*/
|
|
3529
|
+
frequencyHz?: number;
|
|
3530
|
+
/**
|
|
3531
|
+
* [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical
|
|
3532
|
+
* damping.
|
|
3533
|
+
*/
|
|
3534
|
+
dampingRatio?: number;
|
|
3535
|
+
}
|
|
3536
|
+
/**
|
|
3537
|
+
* Mouse joint definition. This requires a world target point, tuning
|
|
3538
|
+
* parameters, and the time step.
|
|
3539
|
+
*/
|
|
3540
|
+
export interface MouseJointDef extends JointDef, MouseJointOpt {
|
|
3541
|
+
/**
|
|
3542
|
+
* The initial world target point. This is assumed to coincide with the body
|
|
3543
|
+
* anchor initially.
|
|
3544
|
+
*/
|
|
3545
|
+
target: Vec2Value;
|
|
3546
|
+
}
|
|
3547
|
+
/**
|
|
3548
|
+
* A mouse joint is used to make a point on a body track a specified world
|
|
3549
|
+
* point. This a soft constraint with a maximum force. This allows the
|
|
3550
|
+
* constraint to stretch and without applying huge forces.
|
|
3551
|
+
*
|
|
3552
|
+
* You need to call setTarget(target) every time that mouse is
|
|
3553
|
+
* moved, to track the new location of the mouse.
|
|
3554
|
+
*
|
|
3555
|
+
* NOTE: this joint is not documented in the manual because it was developed to
|
|
3556
|
+
* be used in the testbed. If you want to learn how to use the mouse joint, look
|
|
3557
|
+
* at the testbed.
|
|
3558
|
+
*/
|
|
3559
|
+
export declare class MouseJoint extends Joint {
|
|
3560
|
+
static TYPE: "mouse-joint";
|
|
3561
|
+
constructor(def: MouseJointDef);
|
|
3562
|
+
constructor(def: MouseJointOpt, bodyA: Body$1, bodyB: Body$1, target?: Vec2Value);
|
|
3563
|
+
/** @hidden */
|
|
3564
|
+
_serialize(): object;
|
|
3565
|
+
/** @hidden */
|
|
3566
|
+
static _deserialize(data: any, world: any, restore: any): MouseJoint;
|
|
3567
|
+
/** @hidden */
|
|
3568
|
+
_reset(def: Partial<MouseJointDef>): void;
|
|
3569
|
+
/**
|
|
3570
|
+
* Use this to update the target point.
|
|
3571
|
+
*/
|
|
3572
|
+
setTarget(target: Vec2Value): void;
|
|
3573
|
+
getTarget(): Vec2Value;
|
|
3574
|
+
/**
|
|
3575
|
+
* Set the maximum force in Newtons.
|
|
3576
|
+
*/
|
|
3577
|
+
setMaxForce(force: number): void;
|
|
3578
|
+
/**
|
|
3579
|
+
* Get the maximum force in Newtons.
|
|
3580
|
+
*/
|
|
3581
|
+
getMaxForce(): number;
|
|
3582
|
+
/**
|
|
3583
|
+
* Set the frequency in Hertz.
|
|
3584
|
+
*/
|
|
3585
|
+
setFrequency(hz: number): void;
|
|
3586
|
+
/**
|
|
3587
|
+
* Get the frequency in Hertz.
|
|
3588
|
+
*/
|
|
3589
|
+
getFrequency(): number;
|
|
3590
|
+
/**
|
|
3591
|
+
* Set the damping ratio (dimensionless).
|
|
3592
|
+
*/
|
|
3593
|
+
setDampingRatio(ratio: number): void;
|
|
3594
|
+
/**
|
|
3595
|
+
* Get the damping ratio (dimensionless).
|
|
3596
|
+
*/
|
|
3597
|
+
getDampingRatio(): number;
|
|
3598
|
+
/**
|
|
3599
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3600
|
+
*/
|
|
3601
|
+
getAnchorA(): Vec2Value;
|
|
3602
|
+
/**
|
|
3603
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3604
|
+
*/
|
|
3605
|
+
getAnchorB(): Vec2Value;
|
|
3606
|
+
/**
|
|
3607
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3608
|
+
*/
|
|
3609
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3610
|
+
/**
|
|
3611
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3612
|
+
*/
|
|
3613
|
+
getReactionTorque(inv_dt: number): number;
|
|
3614
|
+
/**
|
|
3615
|
+
* Shift the origin for any points stored in world coordinates.
|
|
3616
|
+
*/
|
|
3617
|
+
shiftOrigin(newOrigin: Vec2Value): void;
|
|
3618
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3619
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3620
|
+
/**
|
|
3621
|
+
* This returns true if the position errors are within tolerance.
|
|
3622
|
+
*/
|
|
3623
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3624
|
+
}
|
|
3625
|
+
/**
|
|
3626
|
+
* Pulley joint definition. This requires two ground anchors, two dynamic body
|
|
3627
|
+
* anchor points, and a pulley ratio.
|
|
3628
|
+
*/
|
|
3629
|
+
export interface PulleyJointOpt extends JointOpt {
|
|
3630
|
+
}
|
|
3631
|
+
/**
|
|
3632
|
+
* Pulley joint definition. This requires two ground anchors, two dynamic body
|
|
3633
|
+
* anchor points, and a pulley ratio.
|
|
3634
|
+
*/
|
|
3635
|
+
export interface PulleyJointDef extends JointDef, PulleyJointOpt {
|
|
3636
|
+
/**
|
|
3637
|
+
* The first ground anchor in world coordinates. This point never moves.
|
|
3638
|
+
*/
|
|
3639
|
+
groundAnchorA: Vec2Value;
|
|
3640
|
+
/**
|
|
3641
|
+
* The second ground anchor in world coordinates. This point never moves.
|
|
3642
|
+
*/
|
|
3643
|
+
groundAnchorB: Vec2Value;
|
|
3644
|
+
/**
|
|
3645
|
+
* The local anchor point relative to bodyA's origin.
|
|
3646
|
+
*/
|
|
3647
|
+
localAnchorA: Vec2Value;
|
|
3648
|
+
/**
|
|
3649
|
+
* The local anchor point relative to bodyB's origin.
|
|
3650
|
+
*/
|
|
3651
|
+
localAnchorB: Vec2Value;
|
|
3652
|
+
/**
|
|
3653
|
+
* The reference length for the segment attached to bodyA.
|
|
3654
|
+
*/
|
|
3655
|
+
lengthA: number;
|
|
3656
|
+
/**
|
|
3657
|
+
* The reference length for the segment attached to bodyB.
|
|
3658
|
+
*/
|
|
3659
|
+
lengthB: number;
|
|
3660
|
+
/**
|
|
3661
|
+
* The pulley ratio, used to simulate a block-and-tackle.
|
|
3662
|
+
*/
|
|
3663
|
+
ratio: number;
|
|
3664
|
+
/** @hidden */ anchorA?: Vec2Value;
|
|
3665
|
+
/** @hidden */ anchorB?: Vec2Value;
|
|
3666
|
+
}
|
|
3667
|
+
/**
|
|
3668
|
+
* The pulley joint is connected to two bodies and two fixed ground points. The
|
|
3669
|
+
* pulley supports a ratio such that: length1 + ratio * length2 <= constant
|
|
3670
|
+
*
|
|
3671
|
+
* Yes, the force transmitted is scaled by the ratio.
|
|
3672
|
+
*
|
|
3673
|
+
* Warning: the pulley joint can get a bit squirrelly by itself. They often work
|
|
3674
|
+
* better when combined with prismatic joints. You should also cover the the
|
|
3675
|
+
* anchor points with static shapes to prevent one side from going to zero
|
|
3676
|
+
* length.
|
|
3677
|
+
*/
|
|
3678
|
+
export declare class PulleyJoint extends Joint {
|
|
3679
|
+
static TYPE: "pulley-joint";
|
|
3680
|
+
constructor(def: PulleyJointDef);
|
|
3681
|
+
constructor(def: PulleyJointOpt, bodyA: Body$1, bodyB: Body$1, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);
|
|
3682
|
+
/** @hidden */
|
|
3683
|
+
_serialize(): object;
|
|
3684
|
+
/** @hidden */
|
|
3685
|
+
static _deserialize(data: any, world: any, restore: any): PulleyJoint;
|
|
3686
|
+
/** @hidden */
|
|
3687
|
+
_reset(def: Partial<PulleyJointDef>): void;
|
|
3688
|
+
/**
|
|
3689
|
+
* Get the first ground anchor.
|
|
3690
|
+
*/
|
|
3691
|
+
getGroundAnchorA(): Vec2Value;
|
|
3692
|
+
/**
|
|
3693
|
+
* Get the second ground anchor.
|
|
3694
|
+
*/
|
|
3695
|
+
getGroundAnchorB(): Vec2Value;
|
|
3696
|
+
/**
|
|
3697
|
+
* Get the current length of the segment attached to bodyA.
|
|
3698
|
+
*/
|
|
3699
|
+
getLengthA(): number;
|
|
3700
|
+
/**
|
|
3701
|
+
* Get the current length of the segment attached to bodyB.
|
|
3702
|
+
*/
|
|
3703
|
+
getLengthB(): number;
|
|
3704
|
+
/**
|
|
3705
|
+
* Get the pulley ratio.
|
|
3706
|
+
*/
|
|
3707
|
+
getRatio(): number;
|
|
3708
|
+
/**
|
|
3709
|
+
* Get the current length of the segment attached to bodyA.
|
|
3710
|
+
*/
|
|
3711
|
+
getCurrentLengthA(): number;
|
|
3712
|
+
/**
|
|
3713
|
+
* Get the current length of the segment attached to bodyB.
|
|
3714
|
+
*/
|
|
3715
|
+
getCurrentLengthB(): number;
|
|
3716
|
+
/**
|
|
3717
|
+
* Shift the origin for any points stored in world coordinates.
|
|
3718
|
+
*
|
|
3719
|
+
* @param newOrigin
|
|
3720
|
+
*/
|
|
3721
|
+
shiftOrigin(newOrigin: Vec2Value): void;
|
|
3722
|
+
/**
|
|
3723
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3724
|
+
*/
|
|
3725
|
+
getAnchorA(): Vec2Value;
|
|
3726
|
+
/**
|
|
3727
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3728
|
+
*/
|
|
3729
|
+
getAnchorB(): Vec2Value;
|
|
3730
|
+
/**
|
|
3731
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3732
|
+
*/
|
|
3733
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3734
|
+
/**
|
|
3735
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3736
|
+
*/
|
|
3737
|
+
getReactionTorque(inv_dt: number): number;
|
|
3738
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3739
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3740
|
+
/**
|
|
3741
|
+
* This returns true if the position errors are within tolerance.
|
|
3742
|
+
*/
|
|
3743
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3744
|
+
}
|
|
3745
|
+
/**
|
|
3746
|
+
* Rope joint definition. This requires two body anchor points and a maximum
|
|
3747
|
+
* lengths. Note: by default the connected objects will not collide. see
|
|
3748
|
+
* collideConnected in JointDef.
|
|
3749
|
+
*/
|
|
3750
|
+
export interface RopeJointOpt extends JointOpt {
|
|
3751
|
+
/**
|
|
3752
|
+
* The maximum length of the rope.
|
|
3753
|
+
* Warning: this must be larger than linearSlop or the joint will have no effect.
|
|
3754
|
+
*/
|
|
3755
|
+
maxLength?: number;
|
|
3756
|
+
}
|
|
3757
|
+
/**
|
|
3758
|
+
* Rope joint definition. This requires two body anchor points and a maximum
|
|
3759
|
+
* lengths. Note: by default the connected objects will not collide. see
|
|
3760
|
+
* collideConnected in JointDef.
|
|
3761
|
+
*/
|
|
3762
|
+
export interface RopeJointDef extends JointDef, RopeJointOpt {
|
|
3763
|
+
/**
|
|
3764
|
+
* The local anchor point relative to bodyA's origin.
|
|
3765
|
+
*/
|
|
3766
|
+
localAnchorA: Vec2Value;
|
|
3767
|
+
/**
|
|
3768
|
+
* The local anchor point relative to bodyB's origin.
|
|
3769
|
+
*/
|
|
3770
|
+
localAnchorB: Vec2Value;
|
|
3771
|
+
}
|
|
3772
|
+
/**
|
|
3773
|
+
* A rope joint enforces a maximum distance between two points on two bodies. It
|
|
3774
|
+
* has no other effect.
|
|
3775
|
+
*
|
|
3776
|
+
* Warning: if you attempt to change the maximum length during the simulation
|
|
3777
|
+
* you will get some non-physical behavior.
|
|
3778
|
+
*
|
|
3779
|
+
* A model that would allow you to dynamically modify the length would have some
|
|
3780
|
+
* sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you
|
|
3781
|
+
* want to dynamically control length.
|
|
3782
|
+
*/
|
|
3783
|
+
export declare class RopeJoint extends Joint {
|
|
3784
|
+
static TYPE: "rope-joint";
|
|
3785
|
+
constructor(def: RopeJointDef);
|
|
3786
|
+
constructor(def: RopeJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
|
|
3787
|
+
/** @hidden */
|
|
3788
|
+
_serialize(): object;
|
|
3789
|
+
/** @hidden */
|
|
3790
|
+
static _deserialize(data: any, world: any, restore: any): RopeJoint;
|
|
3791
|
+
/** @hidden */
|
|
3792
|
+
_reset(def: Partial<RopeJointDef>): void;
|
|
3793
|
+
/**
|
|
3794
|
+
* The local anchor point relative to bodyA's origin.
|
|
3795
|
+
*/
|
|
3796
|
+
getLocalAnchorA(): Vec2Value;
|
|
3797
|
+
/**
|
|
3798
|
+
* The local anchor point relative to bodyB's origin.
|
|
3799
|
+
*/
|
|
3800
|
+
getLocalAnchorB(): Vec2Value;
|
|
3801
|
+
/**
|
|
3802
|
+
* Set the maximum length of the rope.
|
|
3803
|
+
*/
|
|
3804
|
+
setMaxLength(length: number): void;
|
|
3805
|
+
/**
|
|
3806
|
+
* Get the maximum length of the rope.
|
|
3807
|
+
*/
|
|
3808
|
+
getMaxLength(): number;
|
|
3809
|
+
getLimitState(): number;
|
|
3810
|
+
/**
|
|
3811
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3812
|
+
*/
|
|
3813
|
+
getAnchorA(): Vec2Value;
|
|
3814
|
+
/**
|
|
3815
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3816
|
+
*/
|
|
3817
|
+
getAnchorB(): Vec2Value;
|
|
3818
|
+
/**
|
|
3819
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3820
|
+
*/
|
|
3821
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3822
|
+
/**
|
|
3823
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3824
|
+
*/
|
|
3825
|
+
getReactionTorque(inv_dt: number): number;
|
|
3826
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3827
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3828
|
+
/**
|
|
3829
|
+
* This returns true if the position errors are within tolerance.
|
|
3830
|
+
*/
|
|
3831
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3832
|
+
}
|
|
3833
|
+
/**
|
|
3834
|
+
* Weld joint definition. You need to specify local anchor points where they are
|
|
3835
|
+
* attached and the relative body angle. The position of the anchor points is
|
|
3836
|
+
* important for computing the reaction torque.
|
|
3837
|
+
*/
|
|
3838
|
+
export interface WeldJointOpt extends JointOpt {
|
|
3839
|
+
/**
|
|
3840
|
+
* The mass-spring-damper frequency in Hertz. Rotation only. Disable softness
|
|
3841
|
+
* with a value of 0.
|
|
3842
|
+
*/
|
|
3843
|
+
frequencyHz?: number;
|
|
3844
|
+
/**
|
|
3845
|
+
* The damping ratio. 0 = no damping, 1 = critical damping.
|
|
3846
|
+
*/
|
|
3847
|
+
dampingRatio?: number;
|
|
3848
|
+
/**
|
|
3849
|
+
* The bodyB angle minus bodyA angle in the reference state (radians).
|
|
3850
|
+
*/
|
|
3851
|
+
referenceAngle?: number;
|
|
3852
|
+
}
|
|
3853
|
+
/**
|
|
3854
|
+
* Weld joint definition. You need to specify local anchor points where they are
|
|
3855
|
+
* attached and the relative body angle. The position of the anchor points is
|
|
3856
|
+
* important for computing the reaction torque.
|
|
3857
|
+
*/
|
|
3858
|
+
export interface WeldJointDef extends JointDef, WeldJointOpt {
|
|
3859
|
+
/**
|
|
3860
|
+
* The local anchor point relative to bodyA's origin.
|
|
3861
|
+
*/
|
|
3862
|
+
localAnchorA: Vec2Value;
|
|
3863
|
+
/**
|
|
3864
|
+
* The local anchor point relative to bodyB's origin.
|
|
3865
|
+
*/
|
|
3866
|
+
localAnchorB: Vec2Value;
|
|
3867
|
+
}
|
|
3868
|
+
/**
|
|
3869
|
+
* A weld joint essentially glues two bodies together. A weld joint may distort
|
|
3870
|
+
* somewhat because the island constraint solver is approximate.
|
|
3871
|
+
*/
|
|
3872
|
+
export declare class WeldJoint extends Joint {
|
|
3873
|
+
static TYPE: "weld-joint";
|
|
3874
|
+
constructor(def: WeldJointDef);
|
|
3875
|
+
constructor(def: WeldJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
|
|
3876
|
+
/** @hidden */
|
|
3877
|
+
_serialize(): object;
|
|
3878
|
+
/** @hidden */
|
|
3879
|
+
static _deserialize(data: any, world: any, restore: any): WeldJoint;
|
|
3880
|
+
/** @hidden */
|
|
3881
|
+
_reset(def: Partial<WeldJointDef>): void;
|
|
3882
|
+
/**
|
|
3883
|
+
* The local anchor point relative to bodyA's origin.
|
|
3884
|
+
*/
|
|
3885
|
+
getLocalAnchorA(): Vec2Value;
|
|
3886
|
+
/**
|
|
3887
|
+
* The local anchor point relative to bodyB's origin.
|
|
3888
|
+
*/
|
|
3889
|
+
getLocalAnchorB(): Vec2Value;
|
|
3890
|
+
/**
|
|
3891
|
+
* Get the reference angle.
|
|
3892
|
+
*/
|
|
3893
|
+
getReferenceAngle(): number;
|
|
3894
|
+
/**
|
|
3895
|
+
* Set frequency in Hz.
|
|
3896
|
+
*/
|
|
3897
|
+
setFrequency(hz: number): void;
|
|
3898
|
+
/**
|
|
3899
|
+
* Get frequency in Hz.
|
|
3900
|
+
*/
|
|
3901
|
+
getFrequency(): number;
|
|
3902
|
+
/**
|
|
3903
|
+
* Set damping ratio.
|
|
3904
|
+
*/
|
|
3905
|
+
setDampingRatio(ratio: number): void;
|
|
3906
|
+
/**
|
|
3907
|
+
* Get damping ratio.
|
|
3908
|
+
*/
|
|
3909
|
+
getDampingRatio(): number;
|
|
3910
|
+
/**
|
|
3911
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
3912
|
+
*/
|
|
3913
|
+
getAnchorA(): Vec2Value;
|
|
3914
|
+
/**
|
|
3915
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
3916
|
+
*/
|
|
3917
|
+
getAnchorB(): Vec2Value;
|
|
3918
|
+
/**
|
|
3919
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
3920
|
+
*/
|
|
3921
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
3922
|
+
/**
|
|
3923
|
+
* Get the reaction torque on bodyB in N*m.
|
|
3924
|
+
*/
|
|
3925
|
+
getReactionTorque(inv_dt: number): number;
|
|
3926
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
3927
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
3928
|
+
/**
|
|
3929
|
+
* This returns true if the position errors are within tolerance.
|
|
3930
|
+
*/
|
|
3931
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
3932
|
+
}
|
|
3933
|
+
/**
|
|
3934
|
+
* Wheel joint definition. This requires defining a line of motion using an axis
|
|
3935
|
+
* and an anchor point. The definition uses local anchor points and a local axis
|
|
3936
|
+
* so that the initial configuration can violate the constraint slightly. The
|
|
3937
|
+
* joint translation is zero when the local anchor points coincide in world
|
|
3938
|
+
* space. Using local anchors and a local axis helps when saving and loading a
|
|
3939
|
+
* game.
|
|
3940
|
+
*/
|
|
3941
|
+
export interface WheelJointOpt extends JointOpt {
|
|
3942
|
+
/**
|
|
3943
|
+
* Enable/disable the joint motor.
|
|
3944
|
+
*/
|
|
3945
|
+
enableMotor?: boolean;
|
|
3946
|
+
/**
|
|
3947
|
+
* The maximum motor torque, usually in N-m.
|
|
3948
|
+
*/
|
|
3949
|
+
maxMotorTorque?: number;
|
|
3950
|
+
/**
|
|
3951
|
+
* The desired motor speed in radians per second.
|
|
3952
|
+
*/
|
|
3953
|
+
motorSpeed?: number;
|
|
3954
|
+
/**
|
|
3955
|
+
* Suspension frequency, zero indicates no suspension.
|
|
3956
|
+
*/
|
|
3957
|
+
frequencyHz?: number;
|
|
3958
|
+
/**
|
|
3959
|
+
* Suspension damping ratio, one indicates critical damping.
|
|
3960
|
+
*/
|
|
3961
|
+
dampingRatio?: number;
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Wheel joint definition. This requires defining a line of motion using an axis
|
|
3965
|
+
* and an anchor point. The definition uses local anchor points and a local axis
|
|
3966
|
+
* so that the initial configuration can violate the constraint slightly. The
|
|
3967
|
+
* joint translation is zero when the local anchor points coincide in world
|
|
3968
|
+
* space. Using local anchors and a local axis helps when saving and loading a
|
|
3969
|
+
* game.
|
|
3970
|
+
*/
|
|
3971
|
+
export interface WheelJointDef extends JointDef, WheelJointOpt {
|
|
3972
|
+
/**
|
|
3973
|
+
* The local anchor point relative to bodyA's origin.
|
|
3974
|
+
*/
|
|
3975
|
+
localAnchorA: Vec2Value;
|
|
3976
|
+
/**
|
|
3977
|
+
* The local anchor point relative to bodyB's origin.
|
|
3978
|
+
*/
|
|
3979
|
+
localAnchorB: Vec2Value;
|
|
3980
|
+
/**
|
|
3981
|
+
* The local translation axis in bodyA.
|
|
3982
|
+
*/
|
|
3983
|
+
localAxisA: Vec2Value;
|
|
3984
|
+
}
|
|
3985
|
+
/**
|
|
3986
|
+
* A wheel joint. This joint provides two degrees of freedom: translation along
|
|
3987
|
+
* an axis fixed in bodyA and rotation in the plane. In other words, it is a
|
|
3988
|
+
* point to line constraint with a rotational motor and a linear spring/damper.
|
|
3989
|
+
* This joint is designed for vehicle suspensions.
|
|
3990
|
+
*/
|
|
3991
|
+
export declare class WheelJoint extends Joint {
|
|
3992
|
+
static TYPE: "wheel-joint";
|
|
3993
|
+
constructor(def: WheelJointDef);
|
|
3994
|
+
constructor(def: WheelJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value, axis?: Vec2Value);
|
|
3995
|
+
/** @hidden */
|
|
3996
|
+
_serialize(): object;
|
|
3997
|
+
/** @hidden */
|
|
3998
|
+
static _deserialize(data: any, world: any, restore: any): WheelJoint;
|
|
3999
|
+
/** @hidden */
|
|
4000
|
+
_reset(def: Partial<WheelJointDef>): void;
|
|
4001
|
+
/**
|
|
4002
|
+
* The local anchor point relative to bodyA's origin.
|
|
4003
|
+
*/
|
|
4004
|
+
getLocalAnchorA(): Vec2Value;
|
|
4005
|
+
/**
|
|
4006
|
+
* The local anchor point relative to bodyB's origin.
|
|
4007
|
+
*/
|
|
4008
|
+
getLocalAnchorB(): Vec2Value;
|
|
4009
|
+
/**
|
|
4010
|
+
* The local joint axis relative to bodyA.
|
|
4011
|
+
*/
|
|
4012
|
+
getLocalAxisA(): Vec2Value;
|
|
4013
|
+
/**
|
|
4014
|
+
* Get the current joint translation, usually in meters.
|
|
4015
|
+
*/
|
|
4016
|
+
getJointTranslation(): number;
|
|
4017
|
+
/**
|
|
4018
|
+
* Get the current joint translation speed, usually in meters per second.
|
|
4019
|
+
*/
|
|
4020
|
+
getJointSpeed(): number;
|
|
4021
|
+
/**
|
|
4022
|
+
* Is the joint motor enabled?
|
|
4023
|
+
*/
|
|
4024
|
+
isMotorEnabled(): boolean;
|
|
4025
|
+
/**
|
|
4026
|
+
* Enable/disable the joint motor.
|
|
4027
|
+
*/
|
|
4028
|
+
enableMotor(flag: boolean): void;
|
|
4029
|
+
/**
|
|
4030
|
+
* Set the motor speed, usually in radians per second.
|
|
4031
|
+
*/
|
|
4032
|
+
setMotorSpeed(speed: number): void;
|
|
4033
|
+
/**
|
|
4034
|
+
* Get the motor speed, usually in radians per second.
|
|
4035
|
+
*/
|
|
4036
|
+
getMotorSpeed(): number;
|
|
4037
|
+
/**
|
|
4038
|
+
* Set/Get the maximum motor force, usually in N-m.
|
|
4039
|
+
*/
|
|
4040
|
+
setMaxMotorTorque(torque: number): void;
|
|
4041
|
+
getMaxMotorTorque(): number;
|
|
4042
|
+
/**
|
|
4043
|
+
* Get the current motor torque given the inverse time step, usually in N-m.
|
|
4044
|
+
*/
|
|
4045
|
+
getMotorTorque(inv_dt: number): number;
|
|
4046
|
+
/**
|
|
4047
|
+
* Set/Get the spring frequency in hertz. Setting the frequency to zero disables
|
|
4048
|
+
* the spring.
|
|
4049
|
+
*/
|
|
4050
|
+
setSpringFrequencyHz(hz: number): void;
|
|
4051
|
+
getSpringFrequencyHz(): number;
|
|
4052
|
+
/**
|
|
4053
|
+
* Set/Get the spring damping ratio
|
|
4054
|
+
*/
|
|
4055
|
+
setSpringDampingRatio(ratio: number): void;
|
|
4056
|
+
getSpringDampingRatio(): number;
|
|
4057
|
+
/**
|
|
4058
|
+
* Get the anchor point on bodyA in world coordinates.
|
|
4059
|
+
*/
|
|
4060
|
+
getAnchorA(): Vec2Value;
|
|
4061
|
+
/**
|
|
4062
|
+
* Get the anchor point on bodyB in world coordinates.
|
|
4063
|
+
*/
|
|
4064
|
+
getAnchorB(): Vec2Value;
|
|
4065
|
+
/**
|
|
4066
|
+
* Get the reaction force on bodyB at the joint anchor in Newtons.
|
|
4067
|
+
*/
|
|
4068
|
+
getReactionForce(inv_dt: number): Vec2Value;
|
|
4069
|
+
/**
|
|
4070
|
+
* Get the reaction torque on bodyB in N*m.
|
|
4071
|
+
*/
|
|
4072
|
+
getReactionTorque(inv_dt: number): number;
|
|
4073
|
+
initVelocityConstraints(step: TimeStep): void;
|
|
4074
|
+
solveVelocityConstraints(step: TimeStep): void;
|
|
4075
|
+
/**
|
|
4076
|
+
* This returns true if the position errors are within tolerance.
|
|
4077
|
+
*/
|
|
4078
|
+
solvePositionConstraints(step: TimeStep): boolean;
|
|
4079
|
+
}
|
|
4080
|
+
/**
|
|
4081
|
+
* Tuning constants based on meters-kilograms-seconds (MKS) units.
|
|
4082
|
+
*
|
|
4083
|
+
* Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.
|
|
4084
|
+
*/
|
|
4085
|
+
export declare class Settings {
|
|
4086
|
+
/**
|
|
4087
|
+
* You can use this to change the length scale used by your game.
|
|
4088
|
+
*
|
|
4089
|
+
* For example for inches you could use 39.4.
|
|
4090
|
+
*/
|
|
4091
|
+
static lengthUnitsPerMeter: number;
|
|
4092
|
+
/**
|
|
4093
|
+
* The maximum number of contact points between two convex shapes. Do not change
|
|
4094
|
+
* this value.
|
|
4095
|
+
*/
|
|
4096
|
+
static maxManifoldPoints: number;
|
|
4097
|
+
/**
|
|
4098
|
+
* The maximum number of vertices on a convex polygon. You cannot increase this
|
|
4099
|
+
* too much because BlockAllocator has a maximum object size.
|
|
4100
|
+
*/
|
|
4101
|
+
static maxPolygonVertices: number;
|
|
4102
|
+
/**
|
|
4103
|
+
* This is used to fatten AABBs in the dynamic tree. This allows proxies to move
|
|
4104
|
+
* by a small amount without triggering a tree adjustment. This is in meters.
|
|
4105
|
+
*/
|
|
4106
|
+
static aabbExtension: number;
|
|
4107
|
+
/**
|
|
4108
|
+
* This is used to fatten AABBs in the dynamic tree. This is used to predict the
|
|
4109
|
+
* future position based on the current displacement. This is a dimensionless
|
|
4110
|
+
* multiplier.
|
|
4111
|
+
*/
|
|
4112
|
+
static aabbMultiplier: number;
|
|
4113
|
+
/**
|
|
4114
|
+
* A small length used as a collision and constraint tolerance. Usually it is
|
|
4115
|
+
* chosen to be numerically significant, but visually insignificant.
|
|
4116
|
+
*/
|
|
4117
|
+
static linearSlop: number;
|
|
4118
|
+
/**
|
|
4119
|
+
* A small angle used as a collision and constraint tolerance. Usually it is
|
|
4120
|
+
* chosen to be numerically significant, but visually insignificant.
|
|
4121
|
+
*/
|
|
4122
|
+
static angularSlop: number;
|
|
4123
|
+
/**
|
|
4124
|
+
* The radius of the polygon/edge shape skin. This should not be modified.
|
|
4125
|
+
* Making this smaller means polygons will have an insufficient buffer for
|
|
4126
|
+
* continuous collision. Making it larger may create artifacts for vertex
|
|
4127
|
+
* collision.
|
|
4128
|
+
*/
|
|
4129
|
+
static get polygonRadius(): number;
|
|
4130
|
+
/**
|
|
4131
|
+
* Maximum number of sub-steps per contact in continuous physics simulation.
|
|
4132
|
+
*/
|
|
4133
|
+
static maxSubSteps: number;
|
|
4134
|
+
/**
|
|
4135
|
+
* Maximum number of contacts to be handled to solve a TOI impact.
|
|
4136
|
+
*/
|
|
4137
|
+
static maxTOIContacts: number;
|
|
4138
|
+
/**
|
|
4139
|
+
* Maximum iterations to solve a TOI.
|
|
4140
|
+
*/
|
|
4141
|
+
static maxTOIIterations: number;
|
|
4142
|
+
/**
|
|
4143
|
+
* Maximum iterations to find Distance.
|
|
4144
|
+
*/
|
|
4145
|
+
static maxDistanceIterations: number;
|
|
4146
|
+
/**
|
|
4147
|
+
* A velocity threshold for elastic collisions. Any collision with a relative
|
|
4148
|
+
* linear velocity below this threshold will be treated as inelastic.
|
|
4149
|
+
*/
|
|
4150
|
+
static velocityThreshold: number;
|
|
4151
|
+
/**
|
|
4152
|
+
* The maximum linear position correction used when solving constraints. This
|
|
4153
|
+
* helps to prevent overshoot.
|
|
4154
|
+
*/
|
|
4155
|
+
static maxLinearCorrection: number;
|
|
4156
|
+
/**
|
|
4157
|
+
* The maximum angular position correction used when solving constraints. This
|
|
4158
|
+
* helps to prevent overshoot.
|
|
4159
|
+
*/
|
|
4160
|
+
static maxAngularCorrection: number;
|
|
4161
|
+
/**
|
|
4162
|
+
* The maximum linear velocity of a body. This limit is very large and is used
|
|
4163
|
+
* to prevent numerical problems. You shouldn't need to adjust Settings.
|
|
4164
|
+
*/
|
|
4165
|
+
static maxTranslation: number;
|
|
4166
|
+
/**
|
|
4167
|
+
* The maximum angular velocity of a body. This limit is very large and is used
|
|
4168
|
+
* to prevent numerical problems. You shouldn't need to adjust Settings.
|
|
4169
|
+
*/
|
|
4170
|
+
static maxRotation: number;
|
|
4171
|
+
/**
|
|
4172
|
+
* This scale factor controls how fast overlap is resolved. Ideally this would
|
|
4173
|
+
* be 1 so that overlap is removed in one time step. However using values close
|
|
4174
|
+
* to 1 often lead to overshoot.
|
|
4175
|
+
*/
|
|
4176
|
+
static baumgarte: number;
|
|
4177
|
+
static toiBaugarte: number;
|
|
4178
|
+
/**
|
|
4179
|
+
* The time that a body must be still before it will go to sleep.
|
|
4180
|
+
*/
|
|
4181
|
+
static timeToSleep: number;
|
|
4182
|
+
/**
|
|
4183
|
+
* A body cannot sleep if its linear velocity is above this tolerance.
|
|
4184
|
+
*/
|
|
4185
|
+
static linearSleepTolerance: number;
|
|
4186
|
+
/**
|
|
4187
|
+
* A body cannot sleep if its angular velocity is above this tolerance.
|
|
4188
|
+
*/
|
|
4189
|
+
static angularSleepTolerance: number;
|
|
4190
|
+
}
|
|
4191
|
+
/**
|
|
4192
|
+
* This describes the motion of a body/shape for TOI computation. Shapes are
|
|
4193
|
+
* defined with respect to the body origin, which may not coincide with the
|
|
4194
|
+
* center of mass. However, to support dynamics we must interpolate the center
|
|
4195
|
+
* of mass position.
|
|
4196
|
+
*/
|
|
4197
|
+
export declare class Sweep {
|
|
4198
|
+
/** Local center of mass position */
|
|
4199
|
+
localCenter: Vec2Value;
|
|
4200
|
+
/** World center position */
|
|
4201
|
+
c: Vec2Value;
|
|
4202
|
+
/** World angle */
|
|
4203
|
+
a: number;
|
|
4204
|
+
/** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */
|
|
4205
|
+
alpha0: number;
|
|
4206
|
+
c0: Vec2Value;
|
|
4207
|
+
a0: number;
|
|
4208
|
+
setTransform(xf: TransformValue): void;
|
|
4209
|
+
setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void;
|
|
4210
|
+
/**
|
|
4211
|
+
* Get the interpolated transform at a specific time.
|
|
4212
|
+
*
|
|
4213
|
+
* @param xf
|
|
4214
|
+
* @param beta A factor in [0,1], where 0 indicates alpha0
|
|
4215
|
+
*/
|
|
4216
|
+
getTransform(xf: TransformValue, beta?: number): void;
|
|
4217
|
+
/**
|
|
4218
|
+
* Advance the sweep forward, yielding a new initial state.
|
|
4219
|
+
*
|
|
4220
|
+
* @param alpha The new initial time
|
|
4221
|
+
*/
|
|
4222
|
+
advance(alpha: number): void;
|
|
4223
|
+
forward(): void;
|
|
4224
|
+
/**
|
|
4225
|
+
* normalize the angles in radians to be between -pi and pi.
|
|
4226
|
+
*/
|
|
4227
|
+
normalize(): void;
|
|
4228
|
+
set(that: Sweep): void;
|
|
4229
|
+
}
|
|
4230
|
+
/**
|
|
4231
|
+
* Input parameters for TimeOfImpact.
|
|
4232
|
+
*/
|
|
4233
|
+
export declare class TOIInput {
|
|
4234
|
+
proxyA: DistanceProxy;
|
|
4235
|
+
proxyB: DistanceProxy;
|
|
4236
|
+
sweepA: Sweep;
|
|
4237
|
+
sweepB: Sweep;
|
|
4238
|
+
/** defines sweep interval [0, tMax] */
|
|
4239
|
+
tMax: number;
|
|
4240
|
+
recycle(): void;
|
|
4241
|
+
}
|
|
4242
|
+
export declare enum TOIOutputState {
|
|
4243
|
+
e_unset = -1,
|
|
4244
|
+
e_unknown = 0,
|
|
4245
|
+
e_failed = 1,
|
|
4246
|
+
e_overlapped = 2,
|
|
4247
|
+
e_touching = 3,
|
|
4248
|
+
e_separated = 4
|
|
4249
|
+
}
|
|
4250
|
+
/**
|
|
4251
|
+
* Output parameters for TimeOfImpact.
|
|
4252
|
+
*/
|
|
4253
|
+
export declare class TOIOutput {
|
|
4254
|
+
state: TOIOutputState;
|
|
4255
|
+
t: number;
|
|
4256
|
+
recycle(): void;
|
|
4257
|
+
}
|
|
4258
|
+
/**
|
|
4259
|
+
* Compute the upper bound on time before two shapes penetrate. Time is
|
|
4260
|
+
* represented as a fraction between [0,tMax]. This uses a swept separating axis
|
|
4261
|
+
* and may miss some intermediate, non-tunneling collisions. If you change the
|
|
4262
|
+
* time interval, you should call this function again.
|
|
4263
|
+
*
|
|
4264
|
+
* Note: use Distance to compute the contact point and normal at the time of
|
|
4265
|
+
* impact.
|
|
4266
|
+
*
|
|
4267
|
+
* CCD via the local separating axis method. This seeks progression by computing
|
|
4268
|
+
* the largest time at which separation is maintained.
|
|
4269
|
+
*/
|
|
4270
|
+
export declare const TimeOfImpact: {
|
|
4271
|
+
(output: TOIOutput, input: TOIInput): void;
|
|
4272
|
+
Input: typeof TOIInput;
|
|
4273
|
+
Output: typeof TOIOutput;
|
|
4274
|
+
};
|
|
4275
|
+
/** @hidden */
|
|
4276
|
+
export declare const stats: {
|
|
4277
|
+
gjkCalls: number;
|
|
4278
|
+
gjkIters: number;
|
|
4279
|
+
gjkMaxIters: number;
|
|
4280
|
+
toiTime: number;
|
|
4281
|
+
toiMaxTime: number;
|
|
4282
|
+
toiCalls: number;
|
|
4283
|
+
toiIters: number;
|
|
4284
|
+
toiMaxIters: number;
|
|
4285
|
+
toiRootIters: number;
|
|
4286
|
+
toiMaxRootIters: number;
|
|
4287
|
+
toString(newline?: string): string;
|
|
4288
|
+
};
|
|
4289
|
+
/** @hidden @deprecated Merged with main namespace */
|
|
4290
|
+
export declare const internal: {
|
|
4291
|
+
CollidePolygons: (manifold: Manifold, polyA: PolygonShape, xfA: TransformValue, polyB: PolygonShape, xfB: TransformValue) => void;
|
|
4292
|
+
Settings: typeof Settings;
|
|
4293
|
+
Sweep: typeof Sweep;
|
|
4294
|
+
Manifold: typeof Manifold;
|
|
4295
|
+
Distance: {
|
|
4296
|
+
(output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void;
|
|
4297
|
+
testOverlap: (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue) => boolean;
|
|
4298
|
+
Input: typeof DistanceInput;
|
|
4299
|
+
Output: typeof DistanceOutput;
|
|
4300
|
+
Proxy: typeof DistanceProxy;
|
|
4301
|
+
Cache: typeof SimplexCache;
|
|
4302
|
+
};
|
|
4303
|
+
TimeOfImpact: {
|
|
4304
|
+
(output: TOIOutput, input: TOIInput): void;
|
|
4305
|
+
Input: typeof TOIInput;
|
|
4306
|
+
Output: typeof TOIOutput;
|
|
4307
|
+
};
|
|
4308
|
+
DynamicTree: typeof DynamicTree;
|
|
4309
|
+
stats: {
|
|
4310
|
+
gjkCalls: number;
|
|
4311
|
+
gjkIters: number;
|
|
4312
|
+
gjkMaxIters: number;
|
|
4313
|
+
toiTime: number;
|
|
4314
|
+
toiMaxTime: number;
|
|
4315
|
+
toiCalls: number;
|
|
4316
|
+
toiIters: number;
|
|
4317
|
+
toiMaxIters: number;
|
|
4318
|
+
toiRootIters: number;
|
|
4319
|
+
toiMaxRootIters: number;
|
|
4320
|
+
toString(newline?: string): string;
|
|
4321
|
+
};
|
|
4322
|
+
};
|
|
4323
|
+
|
|
4324
|
+
declare namespace geo {
|
|
4325
|
+
export { absVec2, addVec2, clampVec2, combine2Vec2, combine3Vec2, combine4Vec2, copyTransform, copyVec2, copyVec3, crossNumVec2, crossSubVec2Num, crossVec2Num, crossVec2Vec2, derotNegVec2, derotVec2, detransformTransform, detransformVec2, distSqrVec2, distVec2, dotCrossNumVec2, dotSubVec2, dotVec2, dotVec3, dvp, getRotAngle, inverseMat22, isVec2, lengthSqrVec2, lengthVec2, mat22, mat33, minusCrossNumVec2, minusScaleVec2, minusVec2, mulMat22Vec2, mulMat33Vec2, mulMat33Vec3, mulVec2, mulVec3, negVec2, negVec3, normalizeVec2, normalizeVec2Length, plusCrossNumVec2, plusScaleVec2, plusVec2, plusVec3, rerotVec2, retransformVec2, rotNegVec2, rotSubVec2, rotVec2, rotation, scaleVec2, setRotAngle, setTransform, setVec2, setVec3, solveMat22Num, solveMat33Num, subVec2, symInverseMat33, transform, transformVec2, vec2, vec3, vp, zeroMat22, zeroMat33, zeroVec2, zeroVec3 };
|
|
4326
|
+
}
|
|
4327
|
+
declare namespace planck$1 {
|
|
4328
|
+
export { geo };
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
export {
|
|
4332
|
+
Body$1 as Body,
|
|
4333
|
+
BoxShape as Box,
|
|
4334
|
+
ChainShape as Chain,
|
|
4335
|
+
CircleShape as Circle,
|
|
4336
|
+
EdgeShape as Edge,
|
|
4337
|
+
PolygonShape as Polygon,
|
|
4338
|
+
geo,
|
|
4339
|
+
math as Math,
|
|
4340
|
+
planck$1 as default,
|
|
4341
|
+
};
|
|
4342
|
+
|
|
4343
|
+
export {};
|