@newkrok/nape-js 1.0.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.
@@ -0,0 +1,840 @@
1
+ /**
2
+ * Core engine module — manages access to the compiled nape namespace.
3
+ *
4
+ * The nape-compiled.js file is generated by the prebuild script from the
5
+ * original AMD module. It evaluates synchronously on import, so the
6
+ * namespace is available immediately.
7
+ */
8
+ /**
9
+ * Returns the internal nape namespace object.
10
+ *
11
+ * All wrapper classes use this to access the underlying Haxe-compiled
12
+ * constructors and prototypes.
13
+ *
14
+ * @internal
15
+ */
16
+ declare function getNape(): any;
17
+
18
+ /**
19
+ * 2D vector used for positions, velocities, forces, and other 2D quantities.
20
+ *
21
+ * Many methods return a new Vec2 unless noted as "in-place".
22
+ */
23
+ declare class Vec2 {
24
+ /** @internal Raw Haxe nape Vec2 object. */
25
+ readonly _inner: NapeInner;
26
+ constructor(x?: number, y?: number);
27
+ /** @internal Wrap an existing Haxe Vec2 with caching. */
28
+ static _wrap(inner: NapeInner): Vec2;
29
+ get x(): number;
30
+ set x(value: number);
31
+ get y(): number;
32
+ set y(value: number);
33
+ /** Magnitude of the vector. Setting this scales the vector to the given length. */
34
+ get length(): number;
35
+ set length(value: number);
36
+ /** Angle of the vector in radians (measured from the +x axis). */
37
+ get angle(): number;
38
+ set angle(value: number);
39
+ /** Squared length — avoids a square root when only comparison is needed. */
40
+ lsq(): number;
41
+ /** Copy values from another vector into this one (in-place). */
42
+ set(other: Vec2): this;
43
+ /** Set both components at once (in-place). */
44
+ setxy(x: number, y: number): this;
45
+ /** Return a new copy of this vector. */
46
+ copy(weak?: boolean): Vec2;
47
+ /** Rotate this vector by the given angle in radians (in-place). */
48
+ rotate(angle: number): this;
49
+ /** Reflect this vector about the given axis vector (returns new Vec2). */
50
+ reflect(axis: Vec2, weak?: boolean): Vec2;
51
+ /** Normalize this vector to unit length (in-place). Returns original length. */
52
+ normalise(): number;
53
+ /** Return a new unit-length vector with the same direction. */
54
+ unit(weak?: boolean): Vec2;
55
+ /** Return a new vector = this + other. */
56
+ add(other: Vec2, weak?: boolean): Vec2;
57
+ /** Return a new vector = this + other * scalar. */
58
+ addMul(other: Vec2, scalar: number, weak?: boolean): Vec2;
59
+ /** Return a new vector = this − other. */
60
+ sub(other: Vec2, weak?: boolean): Vec2;
61
+ /** Return a new vector = this * scalar. */
62
+ mul(scalar: number, weak?: boolean): Vec2;
63
+ /** this += other (in-place). */
64
+ addeq(other: Vec2): this;
65
+ /** this -= other (in-place). */
66
+ subeq(other: Vec2): this;
67
+ /** this *= scalar (in-place). */
68
+ muleq(scalar: number): this;
69
+ /** Dot product of this and other. */
70
+ dot(other: Vec2): number;
71
+ /** 2D cross product (returns scalar: this.x*other.y − this.y*other.x). */
72
+ cross(other: Vec2): number;
73
+ /** Return the perpendicular vector (rotated 90° counter-clockwise). */
74
+ perp(weak?: boolean): Vec2;
75
+ /** Release this vector back to the object pool. */
76
+ dispose(): void;
77
+ toString(): string;
78
+ /** Obtain a Vec2 from the object pool (or create a new one). */
79
+ static get(x?: number, y?: number, weak?: boolean): Vec2;
80
+ /** Obtain a weak Vec2 that auto-disposes after a single use. */
81
+ static weak(x?: number, y?: number): Vec2;
82
+ /** Create a Vec2 from polar coordinates. */
83
+ static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
84
+ }
85
+ /** @internal Opaque handle for any Haxe-compiled nape object. */
86
+ type NapeInner = any;
87
+
88
+ /**
89
+ * Axis-aligned bounding box defined by min/max corners or x/y/width/height.
90
+ */
91
+ declare class AABB {
92
+ /** @internal */
93
+ readonly _inner: NapeInner;
94
+ constructor(x?: number, y?: number, width?: number, height?: number);
95
+ /** @internal */
96
+ static _wrap(inner: NapeInner): AABB;
97
+ get min(): Vec2;
98
+ set min(value: Vec2);
99
+ get max(): Vec2;
100
+ set max(value: Vec2);
101
+ get x(): number;
102
+ set x(value: number);
103
+ get y(): number;
104
+ set y(value: number);
105
+ get width(): number;
106
+ set width(value: number);
107
+ get height(): number;
108
+ set height(value: number);
109
+ copy(): AABB;
110
+ toString(): string;
111
+ }
112
+
113
+ /**
114
+ * Generic typed wrapper around Haxe list objects (BodyList, ShapeList, etc.).
115
+ *
116
+ * Provides a modern iterable interface with `for...of`, `length`, `at()`, etc.
117
+ */
118
+ declare class NapeList<T> implements Iterable<T> {
119
+ /** @internal */
120
+ readonly _inner: NapeInner;
121
+ /** @internal Function that wraps a raw Haxe element into its TS counterpart. */
122
+ private readonly _wrap;
123
+ /** @internal */
124
+ constructor(inner: NapeInner, wrap: (inner: NapeInner) => T);
125
+ /** Number of elements in the list. */
126
+ get length(): number;
127
+ /** Get element at index. */
128
+ at(index: number): T;
129
+ /** Add an element to the list. */
130
+ add(item: T & {
131
+ _inner: NapeInner;
132
+ }): void;
133
+ /** Remove an element from the list. */
134
+ remove(item: T & {
135
+ _inner: NapeInner;
136
+ }): void;
137
+ /** Check if the list contains an element. */
138
+ has(item: T & {
139
+ _inner: NapeInner;
140
+ }): boolean;
141
+ /** Remove all elements. */
142
+ clear(): void;
143
+ /** Whether the list is empty. */
144
+ get empty(): boolean;
145
+ /** Push an element to the end. */
146
+ push(item: T & {
147
+ _inner: NapeInner;
148
+ }): void;
149
+ /** Pop the last element. */
150
+ pop(): T;
151
+ /** Shift the first element. */
152
+ shift(): T;
153
+ /** Unshift an element to the front. */
154
+ unshift(item: T & {
155
+ _inner: NapeInner;
156
+ }): void;
157
+ /** Iterate over all elements. */
158
+ [Symbol.iterator](): Iterator<T>;
159
+ /** Convert to a plain array. */
160
+ toArray(): T[];
161
+ /** Apply a function to each element. */
162
+ forEach(fn: (item: T, index: number) => void): void;
163
+ toString(): string;
164
+ }
165
+
166
+ /**
167
+ * Physical material properties applied to shapes.
168
+ */
169
+ declare class Material {
170
+ /** @internal */
171
+ readonly _inner: NapeInner;
172
+ constructor(elasticity?: number, dynamicFriction?: number, staticFriction?: number, density?: number, rollingFriction?: number);
173
+ /** @internal */
174
+ static _wrap(inner: NapeInner): Material;
175
+ get elasticity(): number;
176
+ set elasticity(value: number);
177
+ get dynamicFriction(): number;
178
+ set dynamicFriction(value: number);
179
+ get staticFriction(): number;
180
+ set staticFriction(value: number);
181
+ get density(): number;
182
+ set density(value: number);
183
+ get rollingFriction(): number;
184
+ set rollingFriction(value: number);
185
+ get userData(): Record<string, unknown>;
186
+ copy(): Material;
187
+ toString(): string;
188
+ }
189
+
190
+ /**
191
+ * Fluid properties for shapes that act as fluid regions.
192
+ */
193
+ declare class FluidProperties {
194
+ /** @internal */
195
+ readonly _inner: NapeInner;
196
+ constructor(density?: number, viscosity?: number);
197
+ /** @internal */
198
+ static _wrap(inner: NapeInner): FluidProperties;
199
+ get density(): number;
200
+ set density(value: number);
201
+ get viscosity(): number;
202
+ set viscosity(value: number);
203
+ get gravity(): Vec2;
204
+ set gravity(value: Vec2);
205
+ get userData(): Record<string, unknown>;
206
+ copy(): FluidProperties;
207
+ toString(): string;
208
+ }
209
+
210
+ /**
211
+ * Bit-mask based interaction filter for controlling which shapes
212
+ * collide, sense, or interact as fluids.
213
+ */
214
+ declare class InteractionFilter {
215
+ /** @internal */
216
+ readonly _inner: NapeInner;
217
+ constructor(collisionGroup?: number, collisionMask?: number, sensorGroup?: number, sensorMask?: number, fluidGroup?: number, fluidMask?: number);
218
+ /** @internal */
219
+ static _wrap(inner: NapeInner): InteractionFilter;
220
+ get collisionGroup(): number;
221
+ set collisionGroup(value: number);
222
+ get collisionMask(): number;
223
+ set collisionMask(value: number);
224
+ get sensorGroup(): number;
225
+ set sensorGroup(value: number);
226
+ get sensorMask(): number;
227
+ set sensorMask(value: number);
228
+ get fluidGroup(): number;
229
+ set fluidGroup(value: number);
230
+ get fluidMask(): number;
231
+ set fluidMask(value: number);
232
+ get userData(): Record<string, unknown>;
233
+ shouldCollide(other: InteractionFilter): boolean;
234
+ shouldSense(other: InteractionFilter): boolean;
235
+ shouldFlow(other: InteractionFilter): boolean;
236
+ copy(): InteractionFilter;
237
+ toString(): string;
238
+ }
239
+
240
+ declare enum ShapeType {
241
+ CIRCLE = "CIRCLE",
242
+ POLYGON = "POLYGON"
243
+ }
244
+
245
+ /**
246
+ * Base class for physics shapes (Circle, Polygon).
247
+ */
248
+ declare class Shape {
249
+ /** @internal */
250
+ readonly _inner: NapeInner;
251
+ /** @internal – shapes are created via Circle or Polygon constructors. */
252
+ protected constructor();
253
+ /** @internal */
254
+ static _wrap(inner: NapeInner): Shape;
255
+ get type(): ShapeType;
256
+ get body(): Body;
257
+ set body(value: Body | null);
258
+ get worldCOM(): Vec2;
259
+ get localCOM(): Vec2;
260
+ set localCOM(value: Vec2);
261
+ get area(): number;
262
+ get inertia(): number;
263
+ get angDrag(): number;
264
+ get material(): Material;
265
+ set material(value: Material);
266
+ get filter(): InteractionFilter;
267
+ set filter(value: InteractionFilter);
268
+ get fluidProperties(): FluidProperties;
269
+ set fluidProperties(value: FluidProperties);
270
+ /** Callback types assigned to this shape. */
271
+ get cbTypes(): CbTypeSet;
272
+ get fluidEnabled(): boolean;
273
+ set fluidEnabled(value: boolean);
274
+ get sensorEnabled(): boolean;
275
+ set sensorEnabled(value: boolean);
276
+ get bounds(): AABB;
277
+ /** Cast to Circle — returns the Circle wrapper or null if not a circle. */
278
+ get castCircle(): Shape | null;
279
+ /** Cast to Polygon — returns the Polygon wrapper or null if not a polygon. */
280
+ get castPolygon(): Shape | null;
281
+ isCircle(): boolean;
282
+ isPolygon(): boolean;
283
+ translate(translation: Vec2): void;
284
+ scale(scaleX: number, scaleY: number): void;
285
+ rotate(angle: number): void;
286
+ transform(matrix: {
287
+ _inner: NapeInner;
288
+ }): void;
289
+ contains(point: Vec2): boolean;
290
+ copy(): Shape;
291
+ toString(): string;
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;
360
+
361
+ /**
362
+ * Body type enumeration.
363
+ *
364
+ * - `STATIC` — immovable, infinite mass (walls, floors)
365
+ * - `DYNAMIC` — fully simulated (default)
366
+ * - `KINEMATIC` — moves only via velocity, not affected by forces
367
+ */
368
+ declare enum BodyType {
369
+ STATIC = "STATIC",
370
+ DYNAMIC = "DYNAMIC",
371
+ KINEMATIC = "KINEMATIC"
372
+ }
373
+
374
+ /**
375
+ * A rigid body in the physics simulation.
376
+ */
377
+ declare class Body {
378
+ /** @internal */
379
+ readonly _inner: NapeInner;
380
+ constructor(type?: BodyType, position?: Vec2);
381
+ /** @internal */
382
+ static _wrap(inner: NapeInner): Body;
383
+ get type(): BodyType;
384
+ set type(value: BodyType);
385
+ isStatic(): boolean;
386
+ isDynamic(): boolean;
387
+ isKinematic(): boolean;
388
+ get position(): Vec2;
389
+ set position(value: Vec2);
390
+ get rotation(): number;
391
+ set rotation(value: number);
392
+ get velocity(): Vec2;
393
+ set velocity(value: Vec2);
394
+ get angularVel(): number;
395
+ set angularVel(value: number);
396
+ get kinematicVel(): Vec2;
397
+ set kinematicVel(value: Vec2);
398
+ get kinAngVel(): number;
399
+ set kinAngVel(value: number);
400
+ get surfaceVel(): Vec2;
401
+ set surfaceVel(value: Vec2);
402
+ get force(): Vec2;
403
+ set force(value: Vec2);
404
+ get torque(): number;
405
+ set torque(value: number);
406
+ get mass(): number;
407
+ set mass(value: number);
408
+ get inertia(): number;
409
+ set inertia(value: number);
410
+ get constraintMass(): number;
411
+ get constraintInertia(): number;
412
+ get gravMass(): number;
413
+ set gravMass(value: number);
414
+ get gravMassScale(): number;
415
+ set gravMassScale(value: number);
416
+ get isBullet(): boolean;
417
+ set isBullet(value: boolean);
418
+ get disableCCD(): boolean;
419
+ set disableCCD(value: boolean);
420
+ get allowMovement(): boolean;
421
+ set allowMovement(value: boolean);
422
+ get allowRotation(): boolean;
423
+ set allowRotation(value: boolean);
424
+ get isSleeping(): boolean;
425
+ get shapes(): NapeList<Shape>;
426
+ get space(): Space;
427
+ set space(value: Space | null);
428
+ get compound(): NapeInner;
429
+ set compound(value: {
430
+ _inner: NapeInner;
431
+ } | null);
432
+ get bounds(): AABB;
433
+ get constraintVelocity(): Vec2;
434
+ get localCOM(): Vec2;
435
+ get worldCOM(): Vec2;
436
+ get userData(): Record<string, unknown>;
437
+ integrate(deltaTime: number): void;
438
+ applyImpulse(impulse: Vec2, pos?: Vec2, sleepable?: boolean): void;
439
+ applyAngularImpulse(impulse: number, sleepable?: boolean): void;
440
+ setVelocityFromTarget(targetPosition: Vec2, targetRotation: number, deltaTime: number): void;
441
+ localPointToWorld(point: Vec2, weak?: boolean): Vec2;
442
+ worldPointToLocal(point: Vec2, weak?: boolean): Vec2;
443
+ localVectorToWorld(vector: Vec2, weak?: boolean): Vec2;
444
+ worldVectorToLocal(vector: Vec2, weak?: boolean): Vec2;
445
+ translateShapes(translation: Vec2): void;
446
+ rotateShapes(angle: number): void;
447
+ scaleShapes(scaleX: number, scaleY: number): void;
448
+ align(): void;
449
+ rotate(centre: Vec2, angle: number): void;
450
+ setShapeMaterials(material: Material): void;
451
+ setShapeFilters(filter: InteractionFilter): void;
452
+ setShapeFluidProperties(fluidProperties: FluidProperties): void;
453
+ contains(point: Vec2): boolean;
454
+ crushFactor(): number;
455
+ copy(): Body;
456
+ toString(): string;
457
+ }
458
+
459
+ /**
460
+ * A circular physics shape.
461
+ */
462
+ declare class Circle extends Shape {
463
+ constructor(radius?: number, localCOM?: Vec2, material?: Material, filter?: InteractionFilter);
464
+ /** @internal */
465
+ static _wrap(inner: NapeInner): Circle;
466
+ get radius(): number;
467
+ set radius(value: number);
468
+ }
469
+
470
+ /**
471
+ * A convex polygon physics shape.
472
+ *
473
+ * Use the static helper methods (`box`, `rect`, `regular`) for common shapes.
474
+ */
475
+ declare class Polygon extends Shape {
476
+ constructor(vertices?: Vec2[] | NapeInner, material?: Material, filter?: InteractionFilter);
477
+ /** @internal */
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;
482
+ /** Read-only list of local-space vertices. */
483
+ get localVerts(): NapeInner;
484
+ /** Read-only list of world-space vertices (computed after stepping). */
485
+ get worldVerts(): NapeInner;
486
+ /** Read-only edge list. */
487
+ get edges(): NapeInner;
488
+ /** Validate the polygon geometry. */
489
+ validity(): NapeInner;
490
+ }
491
+
492
+ /**
493
+ * Hierarchical interaction group for controlling interactions
494
+ * between sets of interactors.
495
+ */
496
+ declare class InteractionGroup {
497
+ /** @internal */
498
+ readonly _inner: NapeInner;
499
+ constructor(ignore?: boolean);
500
+ /** @internal */
501
+ static _wrap(inner: NapeInner): InteractionGroup;
502
+ get group(): InteractionGroup;
503
+ set group(value: InteractionGroup | null);
504
+ get ignore(): boolean;
505
+ set ignore(value: boolean);
506
+ toString(): string;
507
+ }
508
+
509
+ /**
510
+ * Callback event types.
511
+ */
512
+ declare enum CbEvent {
513
+ BEGIN = "BEGIN",
514
+ ONGOING = "ONGOING",
515
+ END = "END",
516
+ WAKE = "WAKE",
517
+ SLEEP = "SLEEP",
518
+ BREAK = "BREAK",
519
+ PRE = "PRE"
520
+ }
521
+
522
+ /**
523
+ * Callback type — used to tag interactors so that listeners
524
+ * can filter which interactions they respond to.
525
+ */
526
+ declare class CbType {
527
+ /** @internal */
528
+ readonly _inner: NapeInner;
529
+ constructor();
530
+ /** @internal */
531
+ static _wrap(inner: NapeInner): CbType;
532
+ /** Built-in type matching any body. */
533
+ static get ANY_BODY(): CbType;
534
+ /** Built-in type matching any constraint. */
535
+ static get ANY_CONSTRAINT(): CbType;
536
+ /** Built-in type matching any shape. */
537
+ static get ANY_SHAPE(): CbType;
538
+ /** Built-in type matching any compound. */
539
+ static get ANY_COMPOUND(): CbType;
540
+ }
541
+
542
+ /**
543
+ * Interaction type filter for interaction listeners.
544
+ */
545
+ declare enum InteractionType {
546
+ COLLISION = "COLLISION",
547
+ SENSOR = "SENSOR",
548
+ FLUID = "FLUID",
549
+ ANY = "ANY"
550
+ }
551
+
552
+ /**
553
+ * Return value flags for PreListener handlers.
554
+ */
555
+ declare enum PreFlag {
556
+ ACCEPT = "ACCEPT",
557
+ IGNORE = "IGNORE",
558
+ ACCEPT_ONCE = "ACCEPT_ONCE",
559
+ IGNORE_ONCE = "IGNORE_ONCE"
560
+ }
561
+
562
+ /**
563
+ * Composite callback type option — allows including and excluding CbTypes.
564
+ */
565
+ declare class OptionType {
566
+ /** @internal */
567
+ readonly _inner: NapeInner;
568
+ constructor(cbTypes?: CbType | CbType[]);
569
+ /** @internal */
570
+ static _wrap(inner: NapeInner): OptionType;
571
+ }
572
+
573
+ /**
574
+ * Base class for all listener types.
575
+ * Not instantiated directly — use BodyListener, InteractionListener, etc.
576
+ */
577
+ declare class Listener {
578
+ /** @internal */
579
+ readonly _inner: NapeInner;
580
+ /** @internal */
581
+ protected constructor();
582
+ /** @internal */
583
+ static _wrap(inner: NapeInner): Listener;
584
+ get space(): Space;
585
+ set space(value: Space | null);
586
+ get precedence(): number;
587
+ set precedence(value: number);
588
+ get enabled(): boolean;
589
+ set enabled(value: boolean);
590
+ toString(): string;
591
+ }
592
+
593
+ /**
594
+ * Listener that fires when a body wakes, sleeps, etc.
595
+ */
596
+ declare class BodyListener extends Listener {
597
+ /**
598
+ * @param event The event to listen for (WAKE, SLEEP).
599
+ * @param options CbType or OptionType to filter which bodies trigger this.
600
+ * @param handler Callback function receiving a BodyCallback.
601
+ * @param precedence Lower precedence listeners fire first (default 0).
602
+ */
603
+ constructor(event: CbEvent, options: CbType | OptionType, handler: (callback: any) => void, precedence?: number);
604
+ /** @internal */
605
+ static _wrap(inner: NapeInner): BodyListener;
606
+ }
607
+
608
+ /**
609
+ * Listener that fires on collision/sensor/fluid interactions between bodies.
610
+ */
611
+ declare class InteractionListener extends Listener {
612
+ /**
613
+ * @param event BEGIN, ONGOING, or END.
614
+ * @param interactionType COLLISION, SENSOR, FLUID, or ANY.
615
+ * @param options1 CbType/OptionType for the first interactor.
616
+ * @param options2 CbType/OptionType for the second interactor.
617
+ * @param handler Callback receiving an InteractionCallback.
618
+ * @param precedence Lower values fire first (default 0).
619
+ */
620
+ constructor(event: CbEvent, interactionType: InteractionType, options1: CbType | OptionType, options2: CbType | OptionType, handler: (callback: any) => void, precedence?: number);
621
+ /** @internal */
622
+ static _wrap(inner: NapeInner): InteractionListener;
623
+ }
624
+
625
+ /**
626
+ * Listener that fires on constraint events (WAKE, SLEEP, BREAK).
627
+ */
628
+ declare class ConstraintListener extends Listener {
629
+ constructor(event: CbEvent, options: CbType | OptionType, handler: (callback: any) => void, precedence?: number);
630
+ /** @internal */
631
+ static _wrap(inner: NapeInner): ConstraintListener;
632
+ }
633
+
634
+ /**
635
+ * Listener that fires before collision resolution, allowing
636
+ * the handler to accept/ignore the interaction.
637
+ */
638
+ declare class PreListener extends Listener {
639
+ constructor(interactionType: InteractionType, options1: CbType | OptionType, options2: CbType | OptionType, handler: (callback: NapeInner) => PreFlag | NapeInner, precedence?: number, pure?: boolean);
640
+ /** @internal */
641
+ static _wrap(inner: NapeInner): PreListener;
642
+ }
643
+
644
+ /**
645
+ * Base class for all constraints / joints.
646
+ * Not instantiated directly.
647
+ */
648
+ declare class Constraint {
649
+ /** @internal */
650
+ readonly _inner: NapeInner;
651
+ /** @internal */
652
+ protected constructor();
653
+ /** @internal */
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);
661
+ get active(): boolean;
662
+ set active(value: boolean);
663
+ get ignore(): boolean;
664
+ set ignore(value: boolean);
665
+ get stiff(): boolean;
666
+ set stiff(value: boolean);
667
+ get frequency(): number;
668
+ set frequency(value: number);
669
+ get damping(): number;
670
+ set damping(value: number);
671
+ get maxForce(): number;
672
+ set maxForce(value: number);
673
+ get maxError(): number;
674
+ set maxError(value: number);
675
+ get breakUnderForce(): boolean;
676
+ set breakUnderForce(value: boolean);
677
+ get breakUnderError(): boolean;
678
+ set breakUnderError(value: boolean);
679
+ get removeOnBreak(): boolean;
680
+ set removeOnBreak(value: boolean);
681
+ get isSleeping(): boolean;
682
+ get userData(): Record<string, unknown>;
683
+ impulse(): NapeInner;
684
+ bodyImpulse(body: Body): NapeInner;
685
+ visitBodies(fn: (body: Body) => void): void;
686
+ copy(): Constraint;
687
+ toString(): string;
688
+ }
689
+
690
+ /**
691
+ * A pivot (pin) joint that constrains two bodies to share an anchor point.
692
+ */
693
+ declare class PivotJoint extends Constraint {
694
+ constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2);
695
+ /** @internal */
696
+ static _wrap(inner: NapeInner): PivotJoint;
697
+ get body1(): Body;
698
+ set body1(value: Body | null);
699
+ get body2(): Body;
700
+ set body2(value: Body | null);
701
+ get anchor1(): Vec2;
702
+ set anchor1(value: Vec2);
703
+ get anchor2(): Vec2;
704
+ set anchor2(value: Vec2);
705
+ }
706
+
707
+ /**
708
+ * Constrains the distance between two anchor points on two bodies.
709
+ */
710
+ declare class DistanceJoint extends Constraint {
711
+ constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, jointMin: number, jointMax: number);
712
+ /** @internal */
713
+ static _wrap(inner: NapeInner): DistanceJoint;
714
+ get body1(): Body;
715
+ set body1(value: Body | null);
716
+ get body2(): Body;
717
+ set body2(value: Body | null);
718
+ get anchor1(): Vec2;
719
+ set anchor1(value: Vec2);
720
+ get anchor2(): Vec2;
721
+ set anchor2(value: Vec2);
722
+ get jointMin(): number;
723
+ set jointMin(value: number);
724
+ get jointMax(): number;
725
+ set jointMax(value: number);
726
+ }
727
+
728
+ /**
729
+ * Constrains the relative angle between two bodies.
730
+ */
731
+ declare class AngleJoint extends Constraint {
732
+ constructor(body1: Body | null, body2: Body | null, jointMin: number, jointMax: number, ratio?: number);
733
+ /** @internal */
734
+ static _wrap(inner: NapeInner): AngleJoint;
735
+ get body1(): Body;
736
+ set body1(value: Body | null);
737
+ get body2(): Body;
738
+ set body2(value: Body | null);
739
+ get jointMin(): number;
740
+ set jointMin(value: number);
741
+ get jointMax(): number;
742
+ set jointMax(value: number);
743
+ get ratio(): number;
744
+ set ratio(value: number);
745
+ }
746
+
747
+ /**
748
+ * Weld joint — constrains two bodies to maintain a fixed relative
749
+ * position and angle (like gluing them together).
750
+ */
751
+ declare class WeldJoint extends Constraint {
752
+ constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, phase?: number);
753
+ /** @internal */
754
+ static _wrap(inner: NapeInner): WeldJoint;
755
+ get body1(): Body;
756
+ set body1(value: Body | null);
757
+ get body2(): Body;
758
+ set body2(value: Body | null);
759
+ get anchor1(): Vec2;
760
+ set anchor1(value: Vec2);
761
+ get anchor2(): Vec2;
762
+ set anchor2(value: Vec2);
763
+ get phase(): number;
764
+ set phase(value: number);
765
+ }
766
+
767
+ /**
768
+ * Motor joint — applies angular velocity to rotate bodies relative to each other.
769
+ */
770
+ declare class MotorJoint extends Constraint {
771
+ constructor(body1: Body | null, body2: Body | null, rate: number, ratio?: number);
772
+ /** @internal */
773
+ static _wrap(inner: NapeInner): MotorJoint;
774
+ get body1(): Body;
775
+ set body1(value: Body | null);
776
+ get body2(): Body;
777
+ set body2(value: Body | null);
778
+ get rate(): number;
779
+ set rate(value: number);
780
+ get ratio(): number;
781
+ set ratio(value: number);
782
+ }
783
+
784
+ /**
785
+ * Line joint — constrains body2's anchor to slide along a line
786
+ * defined by body1's anchor and direction.
787
+ */
788
+ declare class LineJoint extends Constraint {
789
+ constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, direction: Vec2, jointMin: number, jointMax: number);
790
+ /** @internal */
791
+ static _wrap(inner: NapeInner): LineJoint;
792
+ get body1(): Body;
793
+ set body1(value: Body | null);
794
+ get body2(): Body;
795
+ set body2(value: Body | null);
796
+ get anchor1(): Vec2;
797
+ set anchor1(value: Vec2);
798
+ get anchor2(): Vec2;
799
+ set anchor2(value: Vec2);
800
+ get direction(): Vec2;
801
+ set direction(value: Vec2);
802
+ get jointMin(): number;
803
+ set jointMin(value: number);
804
+ get jointMax(): number;
805
+ set jointMax(value: number);
806
+ }
807
+
808
+ /**
809
+ * Pulley joint — constrains the sum of distances between four anchor points
810
+ * on four bodies.
811
+ */
812
+ declare class PulleyJoint extends Constraint {
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);
814
+ /** @internal */
815
+ static _wrap(inner: NapeInner): PulleyJoint;
816
+ get body1(): Body;
817
+ set body1(value: Body | null);
818
+ get body2(): Body;
819
+ set body2(value: Body | null);
820
+ get body3(): Body;
821
+ set body3(value: Body | null);
822
+ get body4(): Body;
823
+ set body4(value: Body | null);
824
+ get anchor1(): Vec2;
825
+ set anchor1(value: Vec2);
826
+ get anchor2(): Vec2;
827
+ set anchor2(value: Vec2);
828
+ get anchor3(): Vec2;
829
+ set anchor3(value: Vec2);
830
+ get anchor4(): Vec2;
831
+ set anchor4(value: Vec2);
832
+ get jointMin(): number;
833
+ set jointMin(value: number);
834
+ get jointMax(): number;
835
+ set jointMax(value: number);
836
+ get ratio(): number;
837
+ set ratio(value: number);
838
+ }
839
+
840
+ export { AABB, AngleJoint, Body, BodyListener, BodyType, CbEvent, CbType, Circle, Constraint, ConstraintListener, DistanceJoint, FluidProperties, InteractionFilter, InteractionGroup, InteractionListener, InteractionType, LineJoint, Listener, Material, MotorJoint, NapeList, OptionType, PivotJoint, Polygon, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, Vec2, WeldJoint, getNape };