@newkrok/nape-js 2.1.0 → 3.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.
- package/README.md +7 -1
- package/dist/index.cjs +317 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -189
- package/dist/index.d.ts +153 -189
- package/dist/index.js +317 -418
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ declare function getNape(): any;
|
|
|
22
22
|
*/
|
|
23
23
|
declare class Vec2 {
|
|
24
24
|
/** @internal Raw Haxe nape Vec2 object. */
|
|
25
|
-
_inner:
|
|
25
|
+
readonly _inner: NapeInner;
|
|
26
26
|
constructor(x?: number, y?: number);
|
|
27
|
-
/** @internal Wrap an existing Haxe Vec2
|
|
28
|
-
static _wrap(inner:
|
|
27
|
+
/** @internal Wrap an existing Haxe Vec2 with caching. */
|
|
28
|
+
static _wrap(inner: NapeInner): Vec2;
|
|
29
29
|
get x(): number;
|
|
30
30
|
set x(value: number);
|
|
31
31
|
get y(): number;
|
|
@@ -82,16 +82,18 @@ declare class Vec2 {
|
|
|
82
82
|
/** Create a Vec2 from polar coordinates. */
|
|
83
83
|
static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
|
|
84
84
|
}
|
|
85
|
+
/** @internal Opaque handle for any Haxe-compiled nape object. */
|
|
86
|
+
type NapeInner = any;
|
|
85
87
|
|
|
86
88
|
/**
|
|
87
89
|
* Axis-aligned bounding box defined by min/max corners or x/y/width/height.
|
|
88
90
|
*/
|
|
89
91
|
declare class AABB {
|
|
90
92
|
/** @internal */
|
|
91
|
-
_inner:
|
|
93
|
+
readonly _inner: NapeInner;
|
|
92
94
|
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
93
95
|
/** @internal */
|
|
94
|
-
static _wrap(inner:
|
|
96
|
+
static _wrap(inner: NapeInner): AABB;
|
|
95
97
|
get min(): Vec2;
|
|
96
98
|
set min(value: Vec2);
|
|
97
99
|
get max(): Vec2;
|
|
@@ -115,26 +117,26 @@ declare class AABB {
|
|
|
115
117
|
*/
|
|
116
118
|
declare class NapeList<T> implements Iterable<T> {
|
|
117
119
|
/** @internal */
|
|
118
|
-
_inner:
|
|
120
|
+
readonly _inner: NapeInner;
|
|
119
121
|
/** @internal Function that wraps a raw Haxe element into its TS counterpart. */
|
|
120
|
-
private _wrap;
|
|
122
|
+
private readonly _wrap;
|
|
121
123
|
/** @internal */
|
|
122
|
-
constructor(inner:
|
|
124
|
+
constructor(inner: NapeInner, wrap: (inner: NapeInner) => T);
|
|
123
125
|
/** Number of elements in the list. */
|
|
124
126
|
get length(): number;
|
|
125
127
|
/** Get element at index. */
|
|
126
128
|
at(index: number): T;
|
|
127
129
|
/** Add an element to the list. */
|
|
128
130
|
add(item: T & {
|
|
129
|
-
_inner:
|
|
131
|
+
_inner: NapeInner;
|
|
130
132
|
}): void;
|
|
131
133
|
/** Remove an element from the list. */
|
|
132
134
|
remove(item: T & {
|
|
133
|
-
_inner:
|
|
135
|
+
_inner: NapeInner;
|
|
134
136
|
}): void;
|
|
135
137
|
/** Check if the list contains an element. */
|
|
136
138
|
has(item: T & {
|
|
137
|
-
_inner:
|
|
139
|
+
_inner: NapeInner;
|
|
138
140
|
}): boolean;
|
|
139
141
|
/** Remove all elements. */
|
|
140
142
|
clear(): void;
|
|
@@ -142,7 +144,7 @@ declare class NapeList<T> implements Iterable<T> {
|
|
|
142
144
|
get empty(): boolean;
|
|
143
145
|
/** Push an element to the end. */
|
|
144
146
|
push(item: T & {
|
|
145
|
-
_inner:
|
|
147
|
+
_inner: NapeInner;
|
|
146
148
|
}): void;
|
|
147
149
|
/** Pop the last element. */
|
|
148
150
|
pop(): T;
|
|
@@ -150,7 +152,7 @@ declare class NapeList<T> implements Iterable<T> {
|
|
|
150
152
|
shift(): T;
|
|
151
153
|
/** Unshift an element to the front. */
|
|
152
154
|
unshift(item: T & {
|
|
153
|
-
_inner:
|
|
155
|
+
_inner: NapeInner;
|
|
154
156
|
}): void;
|
|
155
157
|
/** Iterate over all elements. */
|
|
156
158
|
[Symbol.iterator](): Iterator<T>;
|
|
@@ -166,10 +168,10 @@ declare class NapeList<T> implements Iterable<T> {
|
|
|
166
168
|
*/
|
|
167
169
|
declare class Material {
|
|
168
170
|
/** @internal */
|
|
169
|
-
_inner:
|
|
171
|
+
readonly _inner: NapeInner;
|
|
170
172
|
constructor(elasticity?: number, dynamicFriction?: number, staticFriction?: number, density?: number, rollingFriction?: number);
|
|
171
173
|
/** @internal */
|
|
172
|
-
static _wrap(inner:
|
|
174
|
+
static _wrap(inner: NapeInner): Material;
|
|
173
175
|
get elasticity(): number;
|
|
174
176
|
set elasticity(value: number);
|
|
175
177
|
get dynamicFriction(): number;
|
|
@@ -180,7 +182,7 @@ declare class Material {
|
|
|
180
182
|
set density(value: number);
|
|
181
183
|
get rollingFriction(): number;
|
|
182
184
|
set rollingFriction(value: number);
|
|
183
|
-
get userData():
|
|
185
|
+
get userData(): Record<string, unknown>;
|
|
184
186
|
copy(): Material;
|
|
185
187
|
toString(): string;
|
|
186
188
|
}
|
|
@@ -190,17 +192,17 @@ declare class Material {
|
|
|
190
192
|
*/
|
|
191
193
|
declare class FluidProperties {
|
|
192
194
|
/** @internal */
|
|
193
|
-
_inner:
|
|
195
|
+
readonly _inner: NapeInner;
|
|
194
196
|
constructor(density?: number, viscosity?: number);
|
|
195
197
|
/** @internal */
|
|
196
|
-
static _wrap(inner:
|
|
198
|
+
static _wrap(inner: NapeInner): FluidProperties;
|
|
197
199
|
get density(): number;
|
|
198
200
|
set density(value: number);
|
|
199
201
|
get viscosity(): number;
|
|
200
202
|
set viscosity(value: number);
|
|
201
203
|
get gravity(): Vec2;
|
|
202
204
|
set gravity(value: Vec2);
|
|
203
|
-
get userData():
|
|
205
|
+
get userData(): Record<string, unknown>;
|
|
204
206
|
copy(): FluidProperties;
|
|
205
207
|
toString(): string;
|
|
206
208
|
}
|
|
@@ -211,10 +213,10 @@ declare class FluidProperties {
|
|
|
211
213
|
*/
|
|
212
214
|
declare class InteractionFilter {
|
|
213
215
|
/** @internal */
|
|
214
|
-
_inner:
|
|
216
|
+
readonly _inner: NapeInner;
|
|
215
217
|
constructor(collisionGroup?: number, collisionMask?: number, sensorGroup?: number, sensorMask?: number, fluidGroup?: number, fluidMask?: number);
|
|
216
218
|
/** @internal */
|
|
217
|
-
static _wrap(inner:
|
|
219
|
+
static _wrap(inner: NapeInner): InteractionFilter;
|
|
218
220
|
get collisionGroup(): number;
|
|
219
221
|
set collisionGroup(value: number);
|
|
220
222
|
get collisionMask(): number;
|
|
@@ -227,12 +229,9 @@ declare class InteractionFilter {
|
|
|
227
229
|
set fluidGroup(value: number);
|
|
228
230
|
get fluidMask(): number;
|
|
229
231
|
set fluidMask(value: number);
|
|
230
|
-
get userData():
|
|
231
|
-
/** Check if two filters should produce a collision interaction. */
|
|
232
|
+
get userData(): Record<string, unknown>;
|
|
232
233
|
shouldCollide(other: InteractionFilter): boolean;
|
|
233
|
-
/** Check if two filters should produce a sensor interaction. */
|
|
234
234
|
shouldSense(other: InteractionFilter): boolean;
|
|
235
|
-
/** Check if two filters should produce a fluid interaction. */
|
|
236
235
|
shouldFlow(other: InteractionFilter): boolean;
|
|
237
236
|
copy(): InteractionFilter;
|
|
238
237
|
toString(): string;
|
|
@@ -248,15 +247,14 @@ declare enum ShapeType {
|
|
|
248
247
|
*/
|
|
249
248
|
declare class Shape {
|
|
250
249
|
/** @internal */
|
|
251
|
-
_inner:
|
|
250
|
+
readonly _inner: NapeInner;
|
|
252
251
|
/** @internal – shapes are created via Circle or Polygon constructors. */
|
|
253
252
|
protected constructor();
|
|
254
253
|
/** @internal */
|
|
255
|
-
static _wrap(inner:
|
|
254
|
+
static _wrap(inner: NapeInner): Shape;
|
|
256
255
|
get type(): ShapeType;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
set body(value: any);
|
|
256
|
+
get body(): Body;
|
|
257
|
+
set body(value: Body | null);
|
|
260
258
|
get worldCOM(): Vec2;
|
|
261
259
|
get localCOM(): Vec2;
|
|
262
260
|
set localCOM(value: Vec2);
|
|
@@ -270,26 +268,95 @@ declare class Shape {
|
|
|
270
268
|
get fluidProperties(): FluidProperties;
|
|
271
269
|
set fluidProperties(value: FluidProperties);
|
|
272
270
|
/** Callback types assigned to this shape. */
|
|
273
|
-
get cbTypes():
|
|
271
|
+
get cbTypes(): CbTypeSet;
|
|
274
272
|
get fluidEnabled(): boolean;
|
|
275
273
|
set fluidEnabled(value: boolean);
|
|
276
274
|
get sensorEnabled(): boolean;
|
|
277
275
|
set sensorEnabled(value: boolean);
|
|
278
276
|
get bounds(): AABB;
|
|
279
277
|
/** Cast to Circle — returns the Circle wrapper or null if not a circle. */
|
|
280
|
-
get castCircle():
|
|
278
|
+
get castCircle(): Shape | null;
|
|
281
279
|
/** Cast to Polygon — returns the Polygon wrapper or null if not a polygon. */
|
|
282
|
-
get castPolygon():
|
|
280
|
+
get castPolygon(): Shape | null;
|
|
283
281
|
isCircle(): boolean;
|
|
284
282
|
isPolygon(): boolean;
|
|
285
283
|
translate(translation: Vec2): void;
|
|
286
284
|
scale(scaleX: number, scaleY: number): void;
|
|
287
285
|
rotate(angle: number): void;
|
|
288
|
-
transform(matrix:
|
|
286
|
+
transform(matrix: {
|
|
287
|
+
_inner: NapeInner;
|
|
288
|
+
}): void;
|
|
289
289
|
contains(point: Vec2): boolean;
|
|
290
290
|
copy(): Shape;
|
|
291
291
|
toString(): string;
|
|
292
292
|
}
|
|
293
|
+
/** Lightweight typed interface for the callback type set on a shape. */
|
|
294
|
+
interface CbTypeSet {
|
|
295
|
+
readonly _inner: NapeInner;
|
|
296
|
+
add(cbType: {
|
|
297
|
+
_inner: NapeInner;
|
|
298
|
+
}): void;
|
|
299
|
+
remove(cbType: {
|
|
300
|
+
_inner: NapeInner;
|
|
301
|
+
}): void;
|
|
302
|
+
has(cbType: {
|
|
303
|
+
_inner: NapeInner;
|
|
304
|
+
}): boolean;
|
|
305
|
+
clear(): void;
|
|
306
|
+
readonly length: number;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The physics world. Add bodies and constraints, then call `step()` each frame.
|
|
311
|
+
*/
|
|
312
|
+
declare class Space {
|
|
313
|
+
/** @internal */
|
|
314
|
+
readonly _inner: NapeInner;
|
|
315
|
+
constructor(gravity?: Vec2);
|
|
316
|
+
/** @internal */
|
|
317
|
+
static _wrap(inner: NapeInner): Space;
|
|
318
|
+
get gravity(): Vec2;
|
|
319
|
+
set gravity(value: Vec2);
|
|
320
|
+
get worldLinearDrag(): number;
|
|
321
|
+
set worldLinearDrag(value: number);
|
|
322
|
+
get worldAngularDrag(): number;
|
|
323
|
+
set worldAngularDrag(value: number);
|
|
324
|
+
get sortContacts(): boolean;
|
|
325
|
+
set sortContacts(value: boolean);
|
|
326
|
+
get bodies(): NapeList<Body>;
|
|
327
|
+
get liveBodies(): NapeList<Body>;
|
|
328
|
+
get constraints(): NapeInner;
|
|
329
|
+
get liveConstraints(): NapeInner;
|
|
330
|
+
get arbiters(): NapeInner;
|
|
331
|
+
get listeners(): NapeInner;
|
|
332
|
+
get compounds(): NapeInner;
|
|
333
|
+
/** The static world body (always present, immovable). */
|
|
334
|
+
get world(): Body;
|
|
335
|
+
get timeStamp(): number;
|
|
336
|
+
get elapsedTime(): number;
|
|
337
|
+
get broadphase(): NapeInner;
|
|
338
|
+
get userData(): Record<string, unknown>;
|
|
339
|
+
step(deltaTime: number, velocityIterations?: number, positionIterations?: number): void;
|
|
340
|
+
clear(): void;
|
|
341
|
+
visitBodies(fn: (body: Body) => void): void;
|
|
342
|
+
visitConstraints(fn: (constraint: NapeInner) => void): void;
|
|
343
|
+
visitCompounds(fn: (compound: NapeInner) => void): void;
|
|
344
|
+
shapesUnderPoint(point: Vec2, filter?: InteractionFilterLike, output?: NapeInner): NapeInner;
|
|
345
|
+
bodiesUnderPoint(point: Vec2, filter?: InteractionFilterLike, output?: NapeInner): NapeInner;
|
|
346
|
+
shapesInAABB(aabb: AABB, containment?: boolean, strict?: boolean, filter?: InteractionFilterLike, output?: NapeInner): NapeInner;
|
|
347
|
+
bodiesInAABB(aabb: AABB, containment?: boolean, strict?: boolean, filter?: InteractionFilterLike, output?: NapeInner): NapeInner;
|
|
348
|
+
rayCast(ray: {
|
|
349
|
+
_inner: NapeInner;
|
|
350
|
+
} | NapeInner, inner?: boolean, filter?: InteractionFilterLike): NapeInner;
|
|
351
|
+
rayMultiCast(ray: {
|
|
352
|
+
_inner: NapeInner;
|
|
353
|
+
} | NapeInner, inner?: boolean, filter?: InteractionFilterLike, output?: NapeInner): NapeInner;
|
|
354
|
+
toString(): string;
|
|
355
|
+
}
|
|
356
|
+
/** @internal Helper type for filter-like parameters. */
|
|
357
|
+
type InteractionFilterLike = {
|
|
358
|
+
_inner: NapeInner;
|
|
359
|
+
} | NapeInner | undefined;
|
|
293
360
|
|
|
294
361
|
/**
|
|
295
362
|
* Body type enumeration.
|
|
@@ -309,10 +376,10 @@ declare enum BodyType {
|
|
|
309
376
|
*/
|
|
310
377
|
declare class Body {
|
|
311
378
|
/** @internal */
|
|
312
|
-
_inner:
|
|
379
|
+
readonly _inner: NapeInner;
|
|
313
380
|
constructor(type?: BodyType, position?: Vec2);
|
|
314
381
|
/** @internal */
|
|
315
|
-
static _wrap(inner:
|
|
382
|
+
static _wrap(inner: NapeInner): Body;
|
|
316
383
|
get type(): BodyType;
|
|
317
384
|
set type(value: BodyType);
|
|
318
385
|
isStatic(): boolean;
|
|
@@ -356,50 +423,34 @@ declare class Body {
|
|
|
356
423
|
set allowRotation(value: boolean);
|
|
357
424
|
get isSleeping(): boolean;
|
|
358
425
|
get shapes(): NapeList<Shape>;
|
|
359
|
-
get space():
|
|
360
|
-
set space(value:
|
|
361
|
-
get compound():
|
|
362
|
-
set compound(value:
|
|
426
|
+
get space(): Space;
|
|
427
|
+
set space(value: Space | null);
|
|
428
|
+
get compound(): NapeInner;
|
|
429
|
+
set compound(value: {
|
|
430
|
+
_inner: NapeInner;
|
|
431
|
+
} | null);
|
|
363
432
|
get bounds(): AABB;
|
|
364
433
|
get constraintVelocity(): Vec2;
|
|
365
434
|
get localCOM(): Vec2;
|
|
366
435
|
get worldCOM(): Vec2;
|
|
367
|
-
get userData():
|
|
368
|
-
/** Integrate the body forward by deltaTime seconds. */
|
|
436
|
+
get userData(): Record<string, unknown>;
|
|
369
437
|
integrate(deltaTime: number): void;
|
|
370
|
-
/** Apply a linear impulse at an optional world-space point. */
|
|
371
438
|
applyImpulse(impulse: Vec2, pos?: Vec2, sleepable?: boolean): void;
|
|
372
|
-
/** Apply an angular impulse (torque × dt). */
|
|
373
439
|
applyAngularImpulse(impulse: number, sleepable?: boolean): void;
|
|
374
|
-
/** Set velocity so the body reaches the target position/rotation in deltaTime. */
|
|
375
440
|
setVelocityFromTarget(targetPosition: Vec2, targetRotation: number, deltaTime: number): void;
|
|
376
|
-
/** Transform a point from local to world coordinates. */
|
|
377
441
|
localPointToWorld(point: Vec2, weak?: boolean): Vec2;
|
|
378
|
-
/** Transform a point from world to local coordinates. */
|
|
379
442
|
worldPointToLocal(point: Vec2, weak?: boolean): Vec2;
|
|
380
|
-
/** Transform a direction vector from local to world coordinates. */
|
|
381
443
|
localVectorToWorld(vector: Vec2, weak?: boolean): Vec2;
|
|
382
|
-
/** Transform a direction vector from world to local coordinates. */
|
|
383
444
|
worldVectorToLocal(vector: Vec2, weak?: boolean): Vec2;
|
|
384
|
-
/** Translate all shapes on this body by the given offset. */
|
|
385
445
|
translateShapes(translation: Vec2): void;
|
|
386
|
-
/** Rotate all shapes on this body by the given angle. */
|
|
387
446
|
rotateShapes(angle: number): void;
|
|
388
|
-
/** Scale all shapes on this body. */
|
|
389
447
|
scaleShapes(scaleX: number, scaleY: number): void;
|
|
390
|
-
/** Align the body so that its center of mass is at its position. */
|
|
391
448
|
align(): void;
|
|
392
|
-
/** Rotate the body about a world-space centre point. */
|
|
393
449
|
rotate(centre: Vec2, angle: number): void;
|
|
394
|
-
/** Set the material for all shapes on this body. */
|
|
395
450
|
setShapeMaterials(material: Material): void;
|
|
396
|
-
/** Set the interaction filter for all shapes on this body. */
|
|
397
451
|
setShapeFilters(filter: InteractionFilter): void;
|
|
398
|
-
/** Set the fluid properties for all shapes on this body. */
|
|
399
452
|
setShapeFluidProperties(fluidProperties: FluidProperties): void;
|
|
400
|
-
/** Check if a world-space point is inside this body. */
|
|
401
453
|
contains(point: Vec2): boolean;
|
|
402
|
-
/** Crush factor for resolving inter-penetration. */
|
|
403
454
|
crushFactor(): number;
|
|
404
455
|
copy(): Body;
|
|
405
456
|
toString(): string;
|
|
@@ -411,7 +462,7 @@ declare class Body {
|
|
|
411
462
|
declare class Circle extends Shape {
|
|
412
463
|
constructor(radius?: number, localCOM?: Vec2, material?: Material, filter?: InteractionFilter);
|
|
413
464
|
/** @internal */
|
|
414
|
-
static _wrap(inner:
|
|
465
|
+
static _wrap(inner: NapeInner): Circle;
|
|
415
466
|
get radius(): number;
|
|
416
467
|
set radius(value: number);
|
|
417
468
|
}
|
|
@@ -422,107 +473,20 @@ declare class Circle extends Shape {
|
|
|
422
473
|
* Use the static helper methods (`box`, `rect`, `regular`) for common shapes.
|
|
423
474
|
*/
|
|
424
475
|
declare class Polygon extends Shape {
|
|
425
|
-
|
|
426
|
-
* Create a polygon from an array of vertices.
|
|
427
|
-
*
|
|
428
|
-
* @param vertices Array of Vec2 or raw Haxe vertex list.
|
|
429
|
-
* @param material Optional material.
|
|
430
|
-
* @param filter Optional interaction filter.
|
|
431
|
-
*/
|
|
432
|
-
constructor(vertices?: Vec2[] | any, material?: Material, filter?: InteractionFilter);
|
|
476
|
+
constructor(vertices?: Vec2[] | NapeInner, material?: Material, filter?: InteractionFilter);
|
|
433
477
|
/** @internal */
|
|
434
|
-
static _wrap(inner:
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
* Usage: `new Polygon(Polygon.box(100, 50))`
|
|
439
|
-
*/
|
|
440
|
-
static box(width: number, height: number, weak?: boolean): any;
|
|
441
|
-
/**
|
|
442
|
-
* Create vertex list for a rectangle at the given offset.
|
|
443
|
-
*
|
|
444
|
-
* Usage: `new Polygon(Polygon.rect(x, y, w, h))`
|
|
445
|
-
*/
|
|
446
|
-
static rect(x: number, y: number, width: number, height: number, weak?: boolean): any;
|
|
447
|
-
/**
|
|
448
|
-
* Create vertex list for a regular polygon (equilateral triangle, hexagon, etc.).
|
|
449
|
-
*
|
|
450
|
-
* @param xRadius Horizontal radius.
|
|
451
|
-
* @param yRadius Vertical radius.
|
|
452
|
-
* @param sides Number of sides.
|
|
453
|
-
* @param angle Starting angle offset (radians).
|
|
454
|
-
* @param weak Whether returned Vec2s are weak.
|
|
455
|
-
*/
|
|
456
|
-
static regular(xRadius: number, yRadius: number, sides: number, angle?: number, weak?: boolean): any;
|
|
478
|
+
static _wrap(inner: NapeInner): Polygon;
|
|
479
|
+
static box(width: number, height: number, weak?: boolean): NapeInner;
|
|
480
|
+
static rect(x: number, y: number, width: number, height: number, weak?: boolean): NapeInner;
|
|
481
|
+
static regular(xRadius: number, yRadius: number, sides: number, angle?: number, weak?: boolean): NapeInner;
|
|
457
482
|
/** Read-only list of local-space vertices. */
|
|
458
|
-
get localVerts():
|
|
483
|
+
get localVerts(): NapeInner;
|
|
459
484
|
/** Read-only list of world-space vertices (computed after stepping). */
|
|
460
|
-
get worldVerts():
|
|
485
|
+
get worldVerts(): NapeInner;
|
|
461
486
|
/** Read-only edge list. */
|
|
462
|
-
get edges():
|
|
487
|
+
get edges(): NapeInner;
|
|
463
488
|
/** Validate the polygon geometry. */
|
|
464
|
-
validity():
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* The physics world. Add bodies and constraints, then call `step()` each frame.
|
|
469
|
-
*/
|
|
470
|
-
declare class Space {
|
|
471
|
-
/** @internal */
|
|
472
|
-
_inner: any;
|
|
473
|
-
constructor(gravity?: Vec2);
|
|
474
|
-
/** @internal */
|
|
475
|
-
static _wrap(inner: any): Space;
|
|
476
|
-
get gravity(): Vec2;
|
|
477
|
-
set gravity(value: Vec2);
|
|
478
|
-
get worldLinearDrag(): number;
|
|
479
|
-
set worldLinearDrag(value: number);
|
|
480
|
-
get worldAngularDrag(): number;
|
|
481
|
-
set worldAngularDrag(value: number);
|
|
482
|
-
get sortContacts(): boolean;
|
|
483
|
-
set sortContacts(value: boolean);
|
|
484
|
-
get bodies(): NapeList<Body>;
|
|
485
|
-
get liveBodies(): NapeList<Body>;
|
|
486
|
-
get constraints(): any;
|
|
487
|
-
get liveConstraints(): any;
|
|
488
|
-
get arbiters(): any;
|
|
489
|
-
get listeners(): any;
|
|
490
|
-
get compounds(): any;
|
|
491
|
-
/** The static world body (always present, immovable). */
|
|
492
|
-
get world(): Body;
|
|
493
|
-
get timeStamp(): number;
|
|
494
|
-
get elapsedTime(): number;
|
|
495
|
-
get broadphase(): any;
|
|
496
|
-
get userData(): any;
|
|
497
|
-
/**
|
|
498
|
-
* Advance the simulation by one time step.
|
|
499
|
-
*
|
|
500
|
-
* @param deltaTime Time to advance (seconds), e.g. 1/60.
|
|
501
|
-
* @param velocityIterations Velocity solver iterations (default 10).
|
|
502
|
-
* @param positionIterations Position solver iterations (default 10).
|
|
503
|
-
*/
|
|
504
|
-
step(deltaTime: number, velocityIterations?: number, positionIterations?: number): void;
|
|
505
|
-
/** Remove all bodies, constraints, and listeners. */
|
|
506
|
-
clear(): void;
|
|
507
|
-
/** Call `fn` for every body in the space. */
|
|
508
|
-
visitBodies(fn: (body: Body) => void): void;
|
|
509
|
-
/** Call `fn` for every constraint in the space. */
|
|
510
|
-
visitConstraints(fn: (constraint: any) => void): void;
|
|
511
|
-
/** Call `fn` for every compound in the space. */
|
|
512
|
-
visitCompounds(fn: (compound: any) => void): void;
|
|
513
|
-
/** Find shapes under a world-space point. */
|
|
514
|
-
shapesUnderPoint(point: Vec2, filter?: any, output?: any): any;
|
|
515
|
-
/** Find bodies under a world-space point. */
|
|
516
|
-
bodiesUnderPoint(point: Vec2, filter?: any, output?: any): any;
|
|
517
|
-
/** Find shapes inside an AABB. */
|
|
518
|
-
shapesInAABB(aabb: AABB, containment?: boolean, strict?: boolean, filter?: any, output?: any): any;
|
|
519
|
-
/** Find bodies inside an AABB. */
|
|
520
|
-
bodiesInAABB(aabb: AABB, containment?: boolean, strict?: boolean, filter?: any, output?: any): any;
|
|
521
|
-
/** Cast a ray into the space. */
|
|
522
|
-
rayCast(ray: any, inner?: boolean, filter?: any): any;
|
|
523
|
-
/** Cast a ray and return all hits. */
|
|
524
|
-
rayMultiCast(ray: any, inner?: boolean, filter?: any, output?: any): any;
|
|
525
|
-
toString(): string;
|
|
489
|
+
validity(): NapeInner;
|
|
526
490
|
}
|
|
527
491
|
|
|
528
492
|
/**
|
|
@@ -531,14 +495,12 @@ declare class Space {
|
|
|
531
495
|
*/
|
|
532
496
|
declare class InteractionGroup {
|
|
533
497
|
/** @internal */
|
|
534
|
-
_inner:
|
|
498
|
+
readonly _inner: NapeInner;
|
|
535
499
|
constructor(ignore?: boolean);
|
|
536
500
|
/** @internal */
|
|
537
|
-
static _wrap(inner:
|
|
538
|
-
/** Parent group. */
|
|
501
|
+
static _wrap(inner: NapeInner): InteractionGroup;
|
|
539
502
|
get group(): InteractionGroup;
|
|
540
503
|
set group(value: InteractionGroup | null);
|
|
541
|
-
/** If true, interactions between members of this group are ignored. */
|
|
542
504
|
get ignore(): boolean;
|
|
543
505
|
set ignore(value: boolean);
|
|
544
506
|
toString(): string;
|
|
@@ -563,10 +525,10 @@ declare enum CbEvent {
|
|
|
563
525
|
*/
|
|
564
526
|
declare class CbType {
|
|
565
527
|
/** @internal */
|
|
566
|
-
_inner:
|
|
528
|
+
readonly _inner: NapeInner;
|
|
567
529
|
constructor();
|
|
568
530
|
/** @internal */
|
|
569
|
-
static _wrap(inner:
|
|
531
|
+
static _wrap(inner: NapeInner): CbType;
|
|
570
532
|
/** Built-in type matching any body. */
|
|
571
533
|
static get ANY_BODY(): CbType;
|
|
572
534
|
/** Built-in type matching any constraint. */
|
|
@@ -602,10 +564,10 @@ declare enum PreFlag {
|
|
|
602
564
|
*/
|
|
603
565
|
declare class OptionType {
|
|
604
566
|
/** @internal */
|
|
605
|
-
_inner:
|
|
567
|
+
readonly _inner: NapeInner;
|
|
606
568
|
constructor(cbTypes?: CbType | CbType[]);
|
|
607
569
|
/** @internal */
|
|
608
|
-
static _wrap(inner:
|
|
570
|
+
static _wrap(inner: NapeInner): OptionType;
|
|
609
571
|
}
|
|
610
572
|
|
|
611
573
|
/**
|
|
@@ -614,13 +576,13 @@ declare class OptionType {
|
|
|
614
576
|
*/
|
|
615
577
|
declare class Listener {
|
|
616
578
|
/** @internal */
|
|
617
|
-
_inner:
|
|
579
|
+
readonly _inner: NapeInner;
|
|
618
580
|
/** @internal */
|
|
619
581
|
protected constructor();
|
|
620
582
|
/** @internal */
|
|
621
|
-
static _wrap(inner:
|
|
622
|
-
get space():
|
|
623
|
-
set space(value:
|
|
583
|
+
static _wrap(inner: NapeInner): Listener;
|
|
584
|
+
get space(): Space;
|
|
585
|
+
set space(value: Space | null);
|
|
624
586
|
get precedence(): number;
|
|
625
587
|
set precedence(value: number);
|
|
626
588
|
get enabled(): boolean;
|
|
@@ -640,7 +602,7 @@ declare class BodyListener extends Listener {
|
|
|
640
602
|
*/
|
|
641
603
|
constructor(event: CbEvent, options: CbType | OptionType, handler: (callback: any) => void, precedence?: number);
|
|
642
604
|
/** @internal */
|
|
643
|
-
static _wrap(inner:
|
|
605
|
+
static _wrap(inner: NapeInner): BodyListener;
|
|
644
606
|
}
|
|
645
607
|
|
|
646
608
|
/**
|
|
@@ -657,7 +619,7 @@ declare class InteractionListener extends Listener {
|
|
|
657
619
|
*/
|
|
658
620
|
constructor(event: CbEvent, interactionType: InteractionType, options1: CbType | OptionType, options2: CbType | OptionType, handler: (callback: any) => void, precedence?: number);
|
|
659
621
|
/** @internal */
|
|
660
|
-
static _wrap(inner:
|
|
622
|
+
static _wrap(inner: NapeInner): InteractionListener;
|
|
661
623
|
}
|
|
662
624
|
|
|
663
625
|
/**
|
|
@@ -666,7 +628,7 @@ declare class InteractionListener extends Listener {
|
|
|
666
628
|
declare class ConstraintListener extends Listener {
|
|
667
629
|
constructor(event: CbEvent, options: CbType | OptionType, handler: (callback: any) => void, precedence?: number);
|
|
668
630
|
/** @internal */
|
|
669
|
-
static _wrap(inner:
|
|
631
|
+
static _wrap(inner: NapeInner): ConstraintListener;
|
|
670
632
|
}
|
|
671
633
|
|
|
672
634
|
/**
|
|
@@ -674,9 +636,9 @@ declare class ConstraintListener extends Listener {
|
|
|
674
636
|
* the handler to accept/ignore the interaction.
|
|
675
637
|
*/
|
|
676
638
|
declare class PreListener extends Listener {
|
|
677
|
-
constructor(interactionType: InteractionType, options1: CbType | OptionType, options2: CbType | OptionType, handler: (callback:
|
|
639
|
+
constructor(interactionType: InteractionType, options1: CbType | OptionType, options2: CbType | OptionType, handler: (callback: NapeInner) => PreFlag | NapeInner, precedence?: number, pure?: boolean);
|
|
678
640
|
/** @internal */
|
|
679
|
-
static _wrap(inner:
|
|
641
|
+
static _wrap(inner: NapeInner): PreListener;
|
|
680
642
|
}
|
|
681
643
|
|
|
682
644
|
/**
|
|
@@ -685,15 +647,17 @@ declare class PreListener extends Listener {
|
|
|
685
647
|
*/
|
|
686
648
|
declare class Constraint {
|
|
687
649
|
/** @internal */
|
|
688
|
-
_inner:
|
|
650
|
+
readonly _inner: NapeInner;
|
|
689
651
|
/** @internal */
|
|
690
652
|
protected constructor();
|
|
691
653
|
/** @internal */
|
|
692
|
-
static _wrap(inner:
|
|
693
|
-
get space():
|
|
694
|
-
set space(value:
|
|
695
|
-
get compound():
|
|
696
|
-
set compound(value:
|
|
654
|
+
static _wrap(inner: NapeInner): Constraint;
|
|
655
|
+
get space(): Space;
|
|
656
|
+
set space(value: Space | null);
|
|
657
|
+
get compound(): NapeInner;
|
|
658
|
+
set compound(value: {
|
|
659
|
+
_inner: NapeInner;
|
|
660
|
+
} | null);
|
|
697
661
|
get active(): boolean;
|
|
698
662
|
set active(value: boolean);
|
|
699
663
|
get ignore(): boolean;
|
|
@@ -715,9 +679,9 @@ declare class Constraint {
|
|
|
715
679
|
get removeOnBreak(): boolean;
|
|
716
680
|
set removeOnBreak(value: boolean);
|
|
717
681
|
get isSleeping(): boolean;
|
|
718
|
-
get userData():
|
|
719
|
-
impulse():
|
|
720
|
-
bodyImpulse(body: Body):
|
|
682
|
+
get userData(): Record<string, unknown>;
|
|
683
|
+
impulse(): NapeInner;
|
|
684
|
+
bodyImpulse(body: Body): NapeInner;
|
|
721
685
|
visitBodies(fn: (body: Body) => void): void;
|
|
722
686
|
copy(): Constraint;
|
|
723
687
|
toString(): string;
|
|
@@ -729,7 +693,7 @@ declare class Constraint {
|
|
|
729
693
|
declare class PivotJoint extends Constraint {
|
|
730
694
|
constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2);
|
|
731
695
|
/** @internal */
|
|
732
|
-
static _wrap(inner:
|
|
696
|
+
static _wrap(inner: NapeInner): PivotJoint;
|
|
733
697
|
get body1(): Body;
|
|
734
698
|
set body1(value: Body | null);
|
|
735
699
|
get body2(): Body;
|
|
@@ -746,7 +710,7 @@ declare class PivotJoint extends Constraint {
|
|
|
746
710
|
declare class DistanceJoint extends Constraint {
|
|
747
711
|
constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, jointMin: number, jointMax: number);
|
|
748
712
|
/** @internal */
|
|
749
|
-
static _wrap(inner:
|
|
713
|
+
static _wrap(inner: NapeInner): DistanceJoint;
|
|
750
714
|
get body1(): Body;
|
|
751
715
|
set body1(value: Body | null);
|
|
752
716
|
get body2(): Body;
|
|
@@ -767,7 +731,7 @@ declare class DistanceJoint extends Constraint {
|
|
|
767
731
|
declare class AngleJoint extends Constraint {
|
|
768
732
|
constructor(body1: Body | null, body2: Body | null, jointMin: number, jointMax: number, ratio?: number);
|
|
769
733
|
/** @internal */
|
|
770
|
-
static _wrap(inner:
|
|
734
|
+
static _wrap(inner: NapeInner): AngleJoint;
|
|
771
735
|
get body1(): Body;
|
|
772
736
|
set body1(value: Body | null);
|
|
773
737
|
get body2(): Body;
|
|
@@ -787,7 +751,7 @@ declare class AngleJoint extends Constraint {
|
|
|
787
751
|
declare class WeldJoint extends Constraint {
|
|
788
752
|
constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, phase?: number);
|
|
789
753
|
/** @internal */
|
|
790
|
-
static _wrap(inner:
|
|
754
|
+
static _wrap(inner: NapeInner): WeldJoint;
|
|
791
755
|
get body1(): Body;
|
|
792
756
|
set body1(value: Body | null);
|
|
793
757
|
get body2(): Body;
|
|
@@ -806,7 +770,7 @@ declare class WeldJoint extends Constraint {
|
|
|
806
770
|
declare class MotorJoint extends Constraint {
|
|
807
771
|
constructor(body1: Body | null, body2: Body | null, rate: number, ratio?: number);
|
|
808
772
|
/** @internal */
|
|
809
|
-
static _wrap(inner:
|
|
773
|
+
static _wrap(inner: NapeInner): MotorJoint;
|
|
810
774
|
get body1(): Body;
|
|
811
775
|
set body1(value: Body | null);
|
|
812
776
|
get body2(): Body;
|
|
@@ -824,7 +788,7 @@ declare class MotorJoint extends Constraint {
|
|
|
824
788
|
declare class LineJoint extends Constraint {
|
|
825
789
|
constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, direction: Vec2, jointMin: number, jointMax: number);
|
|
826
790
|
/** @internal */
|
|
827
|
-
static _wrap(inner:
|
|
791
|
+
static _wrap(inner: NapeInner): LineJoint;
|
|
828
792
|
get body1(): Body;
|
|
829
793
|
set body1(value: Body | null);
|
|
830
794
|
get body2(): Body;
|
|
@@ -848,7 +812,7 @@ declare class LineJoint extends Constraint {
|
|
|
848
812
|
declare class PulleyJoint extends Constraint {
|
|
849
813
|
constructor(body1: Body | null, body2: Body | null, body3: Body | null, body4: Body | null, anchor1: Vec2, anchor2: Vec2, anchor3: Vec2, anchor4: Vec2, jointMin: number, jointMax: number, ratio?: number);
|
|
850
814
|
/** @internal */
|
|
851
|
-
static _wrap(inner:
|
|
815
|
+
static _wrap(inner: NapeInner): PulleyJoint;
|
|
852
816
|
get body1(): Body;
|
|
853
817
|
set body1(value: Body | null);
|
|
854
818
|
get body2(): Body;
|