@newkrok/nape-js 3.4.13 → 3.5.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/dist/index.d.cts CHANGED
@@ -182,6 +182,12 @@ declare class Vec2 {
182
182
  * @internal
183
183
  */
184
184
  get _inner(): NapeInner;
185
+ /**
186
+ * Creates a Vec2 with the given components. Defaults to (0, 0).
187
+ *
188
+ * @param x - The x component (default 0).
189
+ * @param y - The y component (default 0).
190
+ */
185
191
  constructor(x?: number, y?: number);
186
192
  /** @internal Check that this Vec2 has not been disposed. */
187
193
  private _checkDisposed;
@@ -202,66 +208,230 @@ declare class Vec2 {
202
208
  private static _poolGet;
203
209
  /** @internal Wrap a ZPP_Vec2 (or legacy compiled Vec2) with caching. */
204
210
  static _wrap(inner: any): Vec2;
205
- /** Obtain a Vec2 from the object pool (or create a new one). */
211
+ /**
212
+ * Allocate a Vec2 from the public object pool. If `weak` is true, the vector
213
+ * auto-disposes after a single API call.
214
+ *
215
+ * @param x - The x component (default 0).
216
+ * @param y - The y component (default 0).
217
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
218
+ * @returns A pooled or newly created Vec2.
219
+ * @example
220
+ * const v = Vec2.get(3, 4);
221
+ * // use v ...
222
+ * v.dispose();
223
+ */
206
224
  static get(x?: number, y?: number, weak?: boolean): Vec2;
207
- /** Obtain a weak Vec2 that auto-disposes after a single use. */
225
+ /**
226
+ * Allocate a weak Vec2 (auto-disposes after a single use).
227
+ *
228
+ * @param x - The x component (default 0).
229
+ * @param y - The y component (default 0).
230
+ * @returns A weak, pooled Vec2 that is automatically disposed after one API call.
231
+ */
208
232
  static weak(x?: number, y?: number): Vec2;
209
- /** Create a Vec2 from polar coordinates. */
233
+ /**
234
+ * Create a Vec2 from polar coordinates (length and angle in radians).
235
+ *
236
+ * @param length - The magnitude of the resulting vector.
237
+ * @param angle - The angle in radians, measured counter-clockwise from the +x axis.
238
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
239
+ * @returns A new Vec2 with components `(length * cos(angle), length * sin(angle))`.
240
+ * @example
241
+ * const v = Vec2.fromPolar(1, Math.PI / 4); // 45-degree unit vector
242
+ */
210
243
  static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
211
- /** Squared distance between two Vec2s. */
244
+ /**
245
+ * Squared Euclidean distance between two Vec2s. Avoids a square root when
246
+ * only comparison is needed.
247
+ *
248
+ * @param a - The first Vec2.
249
+ * @param b - The second Vec2.
250
+ * @returns The squared distance `(a.x - b.x)² + (a.y - b.y)²`.
251
+ */
212
252
  static dsq(a: Vec2, b: Vec2): number;
213
- /** Euclidean distance between two Vec2s. */
253
+ /**
254
+ * Euclidean distance between two Vec2s.
255
+ *
256
+ * @param a - The first Vec2.
257
+ * @param b - The second Vec2.
258
+ * @returns The distance `sqrt((a.x - b.x)² + (a.y - b.y)²)`.
259
+ */
214
260
  static distance(a: Vec2, b: Vec2): number;
261
+ /** The x component. */
215
262
  get x(): number;
263
+ /** The x component. */
216
264
  set x(value: number);
265
+ /** The y component. */
217
266
  get y(): number;
267
+ /** The y component. */
218
268
  set y(value: number);
219
- /** Magnitude of the vector. */
269
+ /** Magnitude (Euclidean length) of the vector. */
220
270
  get length(): number;
221
- /** Setting length scales the vector to the given magnitude. */
271
+ /**
272
+ * Setting length scales the vector to the given magnitude. Throws if the
273
+ * vector is zero-length.
274
+ *
275
+ * @param value - The desired magnitude. Must not be NaN.
276
+ */
222
277
  set length(value: number);
223
- /** Angle of the vector in radians (measured from the +x axis). */
278
+ /**
279
+ * Angle of the vector in radians, measured counter-clockwise from the +x
280
+ * axis. Returns 0 for the zero vector.
281
+ */
224
282
  get angle(): number;
225
- /** Setting angle preserves magnitude but rotates to the given angle. */
283
+ /**
284
+ * Setting angle preserves the vector's magnitude and rotates it to the given
285
+ * angle.
286
+ *
287
+ * @param value - The desired angle in radians. Must not be NaN.
288
+ */
226
289
  set angle(value: number);
227
- /** Squared length — avoids a square root when only comparison is needed. */
290
+ /**
291
+ * Returns the squared magnitude. Faster than `length` as it avoids a square
292
+ * root.
293
+ *
294
+ * @returns `x² + y²`.
295
+ */
228
296
  lsq(): number;
229
- /** Copy values from another vector into this one (in-place). Returns this. */
297
+ /**
298
+ * Copy another Vec2's components into this vector in-place.
299
+ *
300
+ * @param vector - The source Vec2 to copy from.
301
+ * @returns `this` for chaining.
302
+ */
230
303
  set(vector: Vec2): this;
231
- /** Set both components at once (in-place). Returns this. */
304
+ /**
305
+ * Set both components at once in-place.
306
+ *
307
+ * @param x - The new x component.
308
+ * @param y - The new y component.
309
+ * @returns `this` for chaining.
310
+ */
232
311
  setxy(x: number, y: number): this;
233
- /** Return a new copy of this vector. */
312
+ /**
313
+ * Return a new Vec2 with the same components.
314
+ *
315
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
316
+ * @returns A copy of this vector.
317
+ */
234
318
  copy(weak?: boolean): Vec2;
235
- /** Rotate this vector by the given angle in radians (in-place). Returns this. */
319
+ /**
320
+ * Rotate this vector by `angle` radians in-place.
321
+ *
322
+ * @param angle - The rotation angle in radians.
323
+ * @returns `this` for chaining.
324
+ */
236
325
  rotate(angle: number): this;
237
- /** Reflect this vector about the given axis vector (returns new Vec2). */
326
+ /**
327
+ * Reflect `vec` about this vector as a normal axis.
328
+ *
329
+ * @param vec - The Vec2 to reflect.
330
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
331
+ * @returns A new Vec2 that is the reflection of `vec` about this vector.
332
+ */
238
333
  reflect(vec: Vec2, weak?: boolean): Vec2;
239
- /** Normalize this vector to unit length (in-place). Returns this. */
334
+ /**
335
+ * Normalise this vector to unit length in-place. Throws for zero-length
336
+ * vectors.
337
+ *
338
+ * @returns `this` for chaining.
339
+ */
240
340
  normalise(): this;
241
- /** Return a new unit-length vector with the same direction. */
341
+ /**
342
+ * Return a new unit-length vector with the same direction. Throws for
343
+ * zero-length vectors.
344
+ *
345
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
346
+ * @returns A normalised copy of this vector.
347
+ */
242
348
  unit(weak?: boolean): Vec2;
243
- /** Return a new vector = this + other. */
349
+ /**
350
+ * Return a new Vec2 equal to `this + other`.
351
+ *
352
+ * @param vector - The Vec2 to add.
353
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
354
+ * @returns A new Vec2 with components `(this.x + other.x, this.y + other.y)`.
355
+ */
244
356
  add(vector: Vec2, weak?: boolean): Vec2;
245
- /** Return a new vector = this + other * scalar. */
357
+ /**
358
+ * Return a new Vec2 equal to `this + other × scalar`.
359
+ *
360
+ * @param vector - The Vec2 to scale and add.
361
+ * @param scalar - The multiplier applied to `vector` before addition.
362
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
363
+ * @returns A new Vec2 with components `(this.x + vector.x * scalar, this.y + vector.y * scalar)`.
364
+ */
246
365
  addMul(vector: Vec2, scalar: number, weak?: boolean): Vec2;
247
- /** Return a new vector = this - other. */
366
+ /**
367
+ * Return a new Vec2 equal to `this − other`.
368
+ *
369
+ * @param vector - The Vec2 to subtract.
370
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
371
+ * @returns A new Vec2 with components `(this.x - other.x, this.y - other.y)`.
372
+ */
248
373
  sub(vector: Vec2, weak?: boolean): Vec2;
249
- /** Return a new vector = this * scalar. */
374
+ /**
375
+ * Return a new Vec2 equal to `this × scalar`.
376
+ *
377
+ * @param scalar - The multiplier.
378
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
379
+ * @returns A new Vec2 with components `(this.x * scalar, this.y * scalar)`.
380
+ */
250
381
  mul(scalar: number, weak?: boolean): Vec2;
251
- /** this += other (in-place). Returns this. */
382
+ /**
383
+ * Add another Vec2 to this in-place (`this += other`).
384
+ *
385
+ * @param vector - The Vec2 to add.
386
+ * @returns `this` for chaining.
387
+ */
252
388
  addeq(vector: Vec2): this;
253
- /** this -= other (in-place). Returns this. */
389
+ /**
390
+ * Subtract another Vec2 from this in-place (`this -= other`).
391
+ *
392
+ * @param vector - The Vec2 to subtract.
393
+ * @returns `this` for chaining.
394
+ */
254
395
  subeq(vector: Vec2): this;
255
- /** this *= scalar (in-place). Returns this. */
396
+ /**
397
+ * Multiply this Vec2 by a scalar in-place (`this ×= scalar`).
398
+ *
399
+ * @param scalar - The multiplier.
400
+ * @returns `this` for chaining.
401
+ */
256
402
  muleq(scalar: number): this;
257
- /** Dot product of this and other. */
403
+ /**
404
+ * Dot product of this and another Vec2.
405
+ *
406
+ * @param vector - The other Vec2.
407
+ * @returns `this.x * other.x + this.y * other.y`.
408
+ */
258
409
  dot(vector: Vec2): number;
259
- /** 2D cross product (returns scalar: this.x*other.y - this.y*other.x). */
410
+ /**
411
+ * 2D cross product (`this.x × other.y − this.y × other.x`). Returns a
412
+ * scalar.
413
+ *
414
+ * @param vector - The other Vec2.
415
+ * @returns The scalar cross product.
416
+ */
260
417
  cross(vector: Vec2): number;
261
- /** Return the perpendicular vector (rotated 90deg counter-clockwise). */
418
+ /**
419
+ * Return the perpendicular vector, rotated 90° counter-clockwise.
420
+ *
421
+ * @param weak - If true, the returned Vec2 is auto-disposed after one use (default false).
422
+ * @returns A new Vec2 with components `(-this.y, this.x)`.
423
+ */
262
424
  perp(weak?: boolean): Vec2;
263
- /** Release this vector back to the object pool. */
425
+ /**
426
+ * Return this Vec2 to the object pool. Throws if already disposed or
427
+ * immutable.
428
+ */
264
429
  dispose(): void;
430
+ /**
431
+ * String representation in the form `{ x: … y: … }`.
432
+ *
433
+ * @returns A human-readable string of this vector's components.
434
+ */
265
435
  toString(): string;
266
436
  }
267
437
  /** @internal Opaque handle for any Haxe-compiled nape object. */
@@ -310,6 +480,12 @@ declare class Vec3 {
310
480
  * @internal
311
481
  */
312
482
  get _inner(): NapeInner;
483
+ /**
484
+ * Create a Vec3 with the given components. Defaults to (0, 0, 0).
485
+ * @param x - The x component.
486
+ * @param y - The y component.
487
+ * @param z - The z component.
488
+ */
313
489
  constructor(x?: number, y?: number, z?: number);
314
490
  /** @internal Check that this Vec3 has not been disposed. */
315
491
  private _checkDisposed;
@@ -317,28 +493,70 @@ declare class Vec3 {
317
493
  private _checkImmutable;
318
494
  /** @internal Wrap a ZPP_Vec3 (or legacy compiled Vec3) with caching. */
319
495
  static _wrap(inner: any): Vec3;
320
- /** Obtain a Vec3 from the object pool (or create a new one). */
496
+ /**
497
+ * Allocate a Vec3 from the public object pool, or create a new one if the pool is empty.
498
+ * @param x - Initial x component (default 0).
499
+ * @param y - Initial y component (default 0).
500
+ * @param z - Initial z component (default 0).
501
+ * @returns A Vec3 initialised with the given components.
502
+ */
321
503
  static get(x?: number, y?: number, z?: number): Vec3;
504
+ /** The x component. */
322
505
  get x(): number;
506
+ /** The x component. */
323
507
  set x(value: number);
508
+ /** The y component. */
324
509
  get y(): number;
510
+ /** The y component. */
325
511
  set y(value: number);
512
+ /** The z component. */
326
513
  get z(): number;
514
+ /** The z component. */
327
515
  set z(value: number);
328
- /** Magnitude of the 3D vector. */
516
+ /**
517
+ * Magnitude of the 3D vector.
518
+ * @returns The Euclidean length `sqrt(x² + y² + z²)`.
519
+ */
329
520
  get length(): number;
330
- /** Setting length scales the vector to the given magnitude. */
521
+ /**
522
+ * Scale the vector to the given magnitude.
523
+ * @throws If the vector has zero length.
524
+ */
331
525
  set length(value: number);
332
- /** Squared length — avoids a square root when only comparison is needed. */
526
+ /**
527
+ * Squared magnitude. Faster than `length` as it avoids a square root.
528
+ * @returns `x² + y² + z²`.
529
+ */
333
530
  lsq(): number;
334
- /** Copy values from another Vec3 into this one (in-place). Returns this. */
531
+ /**
532
+ * Copy another Vec3's components into this one in-place.
533
+ * @param vector - The source Vec3 to copy from.
534
+ * @returns `this` for chaining.
535
+ */
335
536
  set(vector: Vec3): this;
336
- /** Set all three components at once (in-place). Returns this. */
537
+ /**
538
+ * Set all three components at once in-place.
539
+ * @param x - The new x component.
540
+ * @param y - The new y component.
541
+ * @param z - The new z component.
542
+ * @returns `this` for chaining.
543
+ */
337
544
  setxyz(x: number, y: number, z: number): this;
338
- /** Return the x,y components as a Vec2. */
545
+ /**
546
+ * Return the x and y components as a new Vec2.
547
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
548
+ * @returns A new Vec2 containing this vector's x and y components.
549
+ */
339
550
  xy(weak?: boolean): Vec2;
340
- /** Release this Vec3 back to the object pool. */
551
+ /**
552
+ * Return this Vec3 to the object pool.
553
+ * @throws If this Vec3 has already been disposed.
554
+ */
341
555
  dispose(): void;
556
+ /**
557
+ * String representation `{ x: … y: … z: … }`.
558
+ * @returns A human-readable string of the three components.
559
+ */
342
560
  toString(): string;
343
561
  }
344
562
 
@@ -386,40 +604,154 @@ declare class Mat23 {
386
604
  static __name__: string[];
387
605
  zpp_inner: ZPP_Mat23;
388
606
  get _inner(): NapeInner;
607
+ /**
608
+ * Create a Mat23 with the given components. Defaults to the identity matrix `[1 0 0; 0 1 0]`.
609
+ * @param a - Component at row 0, col 0.
610
+ * @param b - Component at row 0, col 1.
611
+ * @param c - Component at row 1, col 0.
612
+ * @param d - Component at row 1, col 1.
613
+ * @param tx - Translation component along x.
614
+ * @param ty - Translation component along y.
615
+ */
389
616
  constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
617
+ /**
618
+ * Create a pure rotation matrix for the given angle in radians.
619
+ * @param angle - Rotation angle in radians.
620
+ * @returns A new Mat23 representing the rotation.
621
+ */
390
622
  static rotation(angle: number): Mat23;
623
+ /**
624
+ * Create a pure translation matrix.
625
+ * @param tx - Translation along x.
626
+ * @param ty - Translation along y.
627
+ * @returns A new Mat23 representing the translation.
628
+ */
391
629
  static translation(tx: number, ty: number): Mat23;
630
+ /**
631
+ * Create a pure scale matrix.
632
+ * @param sx - Scale factor along x.
633
+ * @param sy - Scale factor along y.
634
+ * @returns A new Mat23 representing the scale.
635
+ */
392
636
  static scale(sx: number, sy: number): Mat23;
393
637
  static _wrap(inner: any): Mat23;
394
638
  private _setProp;
639
+ /** Matrix component at row 0, col 0. The matrix layout is `[a b tx; c d ty]`. */
395
640
  get a(): number;
641
+ /** Matrix component at row 0, col 0. The matrix layout is `[a b tx; c d ty]`. */
396
642
  set a(v: number);
643
+ /** Matrix component at row 0, col 1. The matrix layout is `[a b tx; c d ty]`. */
397
644
  get b(): number;
645
+ /** Matrix component at row 0, col 1. The matrix layout is `[a b tx; c d ty]`. */
398
646
  set b(v: number);
647
+ /** Matrix component at row 1, col 0. The matrix layout is `[a b tx; c d ty]`. */
399
648
  get c(): number;
649
+ /** Matrix component at row 1, col 0. The matrix layout is `[a b tx; c d ty]`. */
400
650
  set c(v: number);
651
+ /** Matrix component at row 1, col 1. The matrix layout is `[a b tx; c d ty]`. */
401
652
  get d(): number;
653
+ /** Matrix component at row 1, col 1. The matrix layout is `[a b tx; c d ty]`. */
402
654
  set d(v: number);
655
+ /** Translation component along x. The matrix layout is `[a b tx; c d ty]`. */
403
656
  get tx(): number;
657
+ /** Translation component along x. The matrix layout is `[a b tx; c d ty]`. */
404
658
  set tx(v: number);
659
+ /** Translation component along y. The matrix layout is `[a b tx; c d ty]`. */
405
660
  get ty(): number;
661
+ /** Translation component along y. The matrix layout is `[a b tx; c d ty]`. */
406
662
  set ty(v: number);
663
+ /** The determinant of the linear 2×2 part (ad − bc). */
407
664
  get determinant(): number;
665
+ /**
666
+ * Return a new Mat23 with the same components.
667
+ * @returns A deep copy of this matrix.
668
+ */
408
669
  copy(): Mat23;
670
+ /**
671
+ * Copy all components from another Mat23 into this one in-place.
672
+ * @param matrix - The source matrix to copy from.
673
+ * @returns `this` for chaining.
674
+ */
409
675
  set(matrix: Mat23): this;
676
+ /**
677
+ * Set all six components at once in-place.
678
+ * @param a - Component at row 0, col 0.
679
+ * @param b - Component at row 0, col 1.
680
+ * @param c - Component at row 1, col 0.
681
+ * @param d - Component at row 1, col 1.
682
+ * @param tx - Translation along x.
683
+ * @param ty - Translation along y.
684
+ * @returns `this` for chaining.
685
+ */
410
686
  setAs(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number): this;
687
+ /**
688
+ * Reset to the identity matrix in-place.
689
+ * @returns `this` for chaining.
690
+ */
411
691
  reset(): this;
692
+ /**
693
+ * Return `true` if the matrix is singular (non-invertible) within the engine's epsilon threshold.
694
+ * @returns `true` when the matrix cannot be safely inverted.
695
+ */
412
696
  singular(): boolean;
697
+ /**
698
+ * Return the inverse of this matrix.
699
+ * @returns A new Mat23 that is the inverse of this one.
700
+ * @throws If the matrix is singular.
701
+ */
413
702
  inverse(): Mat23;
703
+ /**
704
+ * Return the transpose of this matrix.
705
+ * @returns A new Mat23 that is the transpose of this one.
706
+ */
414
707
  transpose(): Mat23;
708
+ /**
709
+ * Return `matrix × this` (apply this matrix first, then `matrix`).
710
+ * @param matrix - The matrix to concatenate on the left.
711
+ * @returns A new Mat23 representing the combined transformation.
712
+ */
415
713
  concat(matrix: Mat23): Mat23;
714
+ /**
715
+ * Transform a Vec2 by this matrix. If `noTranslation` is true, only the linear 2×2 part is applied.
716
+ * @param point - The Vec2 to transform.
717
+ * @param noTranslation - When true, the translation components (tx, ty) are ignored.
718
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
719
+ * @returns A new Vec2 with the transformed coordinates.
720
+ */
416
721
  transform(point: Vec2, noTranslation?: boolean, weak?: boolean): Vec2;
722
+ /**
723
+ * Apply the inverse transformation to a Vec2. Throws if the matrix is singular.
724
+ * @param point - The Vec2 to transform.
725
+ * @param noTranslation - When true, the translation components (tx, ty) are ignored.
726
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
727
+ * @returns A new Vec2 with the inverse-transformed coordinates.
728
+ */
417
729
  inverseTransform(point: Vec2, noTranslation?: boolean, weak?: boolean): Vec2;
730
+ /**
731
+ * Return `true` if the matrix is equiorthogonal (uniform scale, no shear).
732
+ * @returns `true` when the matrix has equal scale on both axes and no shear.
733
+ */
418
734
  equiorthogonal(): boolean;
735
+ /**
736
+ * Return `true` if the matrix is orthogonal (unit-scale rotation, no shear).
737
+ * @returns `true` when the column vectors are orthonormal.
738
+ */
419
739
  orthogonal(): boolean;
420
740
  private _orthogonaliseImpl;
741
+ /**
742
+ * Adjust the matrix in-place to be equiorthogonal (uniform scale, no shear).
743
+ * @returns `this` for chaining.
744
+ */
421
745
  equiorthogonalise(): this;
746
+ /**
747
+ * Adjust the matrix in-place to be orthogonal (normalise column vectors).
748
+ * @returns `this` for chaining.
749
+ */
422
750
  orthogonalise(): this;
751
+ /**
752
+ * String representation `{ a: … b: … c: … d: … tx: … ty: … }`.
753
+ * @returns A human-readable string of the matrix components.
754
+ */
423
755
  toString(): string;
424
756
  }
425
757
 
@@ -618,26 +950,72 @@ declare class AABB {
618
950
  * @internal
619
951
  */
620
952
  get _inner(): NapeInner;
953
+ /**
954
+ * Create an AABB at position (x, y) with the given width and height. All
955
+ * values default to 0.
956
+ *
957
+ * @param x - The x position of the left edge (default 0).
958
+ * @param y - The y position of the top edge (default 0).
959
+ * @param width - The width of the box (default 0). Must be ≥ 0.
960
+ * @param height - The height of the box (default 0). Must be ≥ 0.
961
+ */
621
962
  constructor(x?: number, y?: number, width?: number, height?: number);
622
963
  /** @internal Wrap a ZPP_AABB (or legacy compiled AABB) with caching. */
623
964
  static _wrap(inner: any): AABB;
965
+ /** The x position of the left edge (minx). Setting shifts the box horizontally. */
624
966
  get x(): number;
967
+ /** The x position of the left edge (minx). Setting shifts the box horizontally. */
625
968
  set x(x: number);
969
+ /** The y position of the top edge (miny). Setting shifts the box vertically. */
626
970
  get y(): number;
971
+ /** The y position of the top edge (miny). Setting shifts the box vertically. */
627
972
  set y(y: number);
973
+ /** Width of the box (maxx − minx). Must be ≥ 0. */
628
974
  get width(): number;
975
+ /** Width of the box (maxx − minx). Must be ≥ 0. */
629
976
  set width(width: number);
977
+ /** Height of the box (maxy − miny). Must be ≥ 0. */
630
978
  get height(): number;
979
+ /** Height of the box (maxy − miny). Must be ≥ 0. */
631
980
  set height(height: number);
981
+ /**
982
+ * The top-left corner as a Vec2 (minx, miny). The returned Vec2 is a live
983
+ * view; mutating it updates the AABB.
984
+ */
632
985
  get min(): any;
986
+ /**
987
+ * Set the top-left corner. The new min must not exceed the current max.
988
+ *
989
+ * @param min - A Vec2 whose components become the new (minx, miny).
990
+ */
633
991
  set min(min: any);
992
+ /**
993
+ * The bottom-right corner as a Vec2 (maxx, maxy). The returned Vec2 is a
994
+ * live view; mutating it updates the AABB.
995
+ */
634
996
  get max(): any;
997
+ /**
998
+ * Set the bottom-right corner. The new max must not be below the current
999
+ * min.
1000
+ *
1001
+ * @param max - A Vec2 whose components become the new (maxx, maxy).
1002
+ */
635
1003
  set max(max: any);
636
1004
  /** @internal Assign source Vec2 values to target Vec2 wrapper. */
637
1005
  private _assignVec2;
638
1006
  /** @internal Dispose a weak Vec2 back to the pool. */
639
1007
  private _disposeVec2;
1008
+ /**
1009
+ * Return a new AABB with the same bounds.
1010
+ *
1011
+ * @returns A copy of this AABB.
1012
+ */
640
1013
  copy(): AABB;
1014
+ /**
1015
+ * String representation in the form `{ x: … y: … w: … h: … }`.
1016
+ *
1017
+ * @returns A human-readable string of this AABB's position and dimensions.
1018
+ */
641
1019
  toString(): string;
642
1020
  }
643
1021
 
@@ -666,14 +1044,47 @@ declare class MatMN {
666
1044
  static __name__: string[];
667
1045
  zpp_inner: ZPP_MatMN;
668
1046
  get _inner(): NapeInner;
1047
+ /**
1048
+ * Create a zero-filled M×N matrix. Both dimensions must be ≥ 1.
1049
+ * @param rows - Number of rows (must be ≥ 1).
1050
+ * @param cols - Number of columns (must be ≥ 1).
1051
+ */
669
1052
  constructor(rows: number, cols: number);
670
1053
  static _wrap(inner: ZPP_MatMN | MatMN | null): MatMN;
1054
+ /** Number of rows. */
671
1055
  get rows(): number;
1056
+ /** Number of columns. */
672
1057
  get cols(): number;
1058
+ /**
1059
+ * Read the element at (row, col). Zero-based indices.
1060
+ * @param row - Zero-based row index.
1061
+ * @param col - Zero-based column index.
1062
+ * @returns The element value at the given position.
1063
+ */
673
1064
  x(row: number, col: number): number;
1065
+ /**
1066
+ * Write `value` to the element at (row, col). Returns the written value.
1067
+ * @param row - Zero-based row index.
1068
+ * @param col - Zero-based column index.
1069
+ * @param value - The value to write.
1070
+ * @returns The written value.
1071
+ */
674
1072
  setx(row: number, col: number, value: number): number;
1073
+ /**
1074
+ * String representation with rows separated by semicolons.
1075
+ * @returns A human-readable string of the matrix elements.
1076
+ */
675
1077
  toString(): string;
1078
+ /**
1079
+ * Return a new transposed matrix (N×M).
1080
+ * @returns A new MatMN that is the transpose of this one.
1081
+ */
676
1082
  transpose(): MatMN;
1083
+ /**
1084
+ * Return the matrix product `this × matrix`. Column count of this must equal row count of `matrix`.
1085
+ * @param matrix - The right-hand matrix to multiply by.
1086
+ * @returns A new MatMN representing the product.
1087
+ */
677
1088
  mul(matrix: MatMN): MatMN;
678
1089
  }
679
1090
 
@@ -758,19 +1169,53 @@ declare class Ray {
758
1169
  zpp_inner: ZPP_Ray;
759
1170
  /** Backward-compat alias for compiled code. */
760
1171
  get _inner(): this;
1172
+ /**
1173
+ * Create a Ray from an origin point and a direction vector.
1174
+ * Both must be non-null, non-disposed Vec2s.
1175
+ * @param origin - The start point of the ray in world coordinates.
1176
+ * @param direction - The direction vector (need not be unit length).
1177
+ */
761
1178
  constructor(origin: Vec2, direction: Vec2);
762
1179
  /** @internal */
763
1180
  static _wrap(inner: ZPP_Ray | Ray | null): Ray;
1181
+ /**
1182
+ * Create a Ray from a line segment.
1183
+ * The ray origin is `start`, direction is `end − start`, and `maxDistance` is the segment length.
1184
+ * @param start - The start point of the segment.
1185
+ * @param end - The end point of the segment.
1186
+ * @returns A new Ray spanning the segment.
1187
+ */
764
1188
  static fromSegment(start: Vec2, end: Vec2): Ray;
1189
+ /** The ray's start point in world coordinates. */
765
1190
  get origin(): Vec2;
1191
+ /** The ray's start point in world coordinates. */
766
1192
  set origin(value: Vec2);
1193
+ /** The ray's direction vector (need not be unit length; the engine normalises internally). */
767
1194
  get direction(): Vec2;
1195
+ /** The ray's direction vector (need not be unit length; the engine normalises internally). */
768
1196
  set direction(value: Vec2);
1197
+ /** Maximum travel distance for raycasting queries. Defaults to `Infinity`. */
769
1198
  get maxDistance(): number;
1199
+ /** Maximum travel distance for raycasting queries. Defaults to `Infinity`. */
770
1200
  set maxDistance(value: number);
1201
+ /** Arbitrary user data attached to this Ray. */
771
1202
  get userData(): Record<string, unknown>;
1203
+ /**
1204
+ * Compute the axis-aligned bounding box that encloses the ray from origin to `maxDistance`.
1205
+ * @returns A new AABB wrapping the ray's extent.
1206
+ */
772
1207
  aabb(): AABB;
1208
+ /**
1209
+ * Return the world-space point at `distance` along the ray.
1210
+ * @param distance - Distance from the ray origin along the ray direction.
1211
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
1212
+ * @returns The point `origin + distance * normalised_direction`.
1213
+ */
773
1214
  at(distance: number, weak?: boolean): Vec2;
1215
+ /**
1216
+ * Return a new Ray with the same origin, direction, and maxDistance.
1217
+ * @returns A deep copy of this Ray.
1218
+ */
774
1219
  copy(): Ray;
775
1220
  /** @internal */ get_origin(): Vec2;
776
1221
  /** @internal */ set_origin(v: Vec2): Vec2;
@@ -1197,10 +1642,22 @@ declare class ZPP_Constraint {
1197
1642
  }
1198
1643
 
1199
1644
  /**
1200
- * Base class for all constraints / joints.
1645
+ * Base class for all physics constraints (joints).
1646
+ *
1647
+ * Constraints restrict the relative motion of two bodies. This class provides
1648
+ * properties common to all joint types: `active`, `stiff`, `frequency`,
1649
+ * `damping`, `maxForce`, `maxError`, `breakUnderForce`, `breakUnderError`,
1650
+ * `removeOnBreak`, `isSleeping`, `space`, `compound`, `cbTypes`, and `userData`.
1651
+ *
1652
+ * Cannot be instantiated directly — use one of the concrete joint subclasses:
1653
+ * {@link AngleJoint}, {@link DistanceJoint}, {@link LineJoint}, {@link MotorJoint},
1654
+ * {@link PivotJoint}, {@link PulleyJoint}, {@link WeldJoint}, or {@link UserConstraint}.
1655
+ *
1656
+ * **Soft vs. stiff constraints:**
1657
+ * - `stiff = true` (default): the constraint is enforced rigidly.
1658
+ * - `stiff = false`: uses a spring model with `frequency` (Hz) and `damping` (ratio).
1201
1659
  *
1202
1660
  * Fully modernized — uses ZPP_Constraint directly (extracted to TypeScript).
1203
- * Not instantiated directly; only via joint subclasses.
1204
1661
  */
1205
1662
  declare class Constraint {
1206
1663
  static __name__: string[];
@@ -1219,36 +1676,145 @@ declare class Constraint {
1219
1676
  protected constructor();
1220
1677
  /** @internal */
1221
1678
  static _wrap(inner: any): Constraint;
1679
+ /**
1680
+ * The space this constraint belongs to, or `null` if not in a space.
1681
+ *
1682
+ * Assign to add/remove the constraint from a space:
1683
+ * ```ts
1684
+ * joint.space = mySpace; // adds to space
1685
+ * joint.space = null; // removes from space
1686
+ * ```
1687
+ * Cannot be set if the constraint belongs to a {@link Compound}.
1688
+ */
1222
1689
  get space(): Space | null;
1223
1690
  set space(value: Space | null);
1691
+ /**
1692
+ * The compound this constraint belongs to, or `null`.
1693
+ * When set, the constraint's `space` is managed by the compound.
1694
+ */
1224
1695
  get compound(): Compound | null;
1225
1696
  set compound(value: Compound | null);
1697
+ /**
1698
+ * Whether the constraint is currently active (enforced by the solver).
1699
+ *
1700
+ * Deactivating a constraint suspends it without removing it from the space.
1701
+ * @defaultValue `true`
1702
+ */
1226
1703
  get active(): boolean;
1227
1704
  set active(value: boolean);
1705
+ /**
1706
+ * When `true` the constraint is completely ignored by the engine — bodies are
1707
+ * not woken, no impulse is applied, and no callbacks fire.
1708
+ * @defaultValue `false`
1709
+ */
1228
1710
  get ignore(): boolean;
1229
1711
  set ignore(value: boolean);
1712
+ /**
1713
+ * When `true` (default) the constraint is stiff/rigid.
1714
+ * When `false` the constraint uses a soft spring model driven by
1715
+ * `frequency` and `damping`.
1716
+ * @defaultValue `true`
1717
+ */
1230
1718
  get stiff(): boolean;
1231
1719
  set stiff(value: boolean);
1720
+ /**
1721
+ * Spring frequency in Hz for soft constraints (`stiff = false`).
1722
+ *
1723
+ * Higher values make the spring stiffer; lower values make it bouncier.
1724
+ * Must be `> 0`. Ignored when `stiff` is `true`.
1725
+ * @defaultValue `10`
1726
+ */
1232
1727
  get frequency(): number;
1233
1728
  set frequency(value: number);
1729
+ /**
1730
+ * Damping ratio for soft constraints (`stiff = false`).
1731
+ *
1732
+ * `0` = undamped (oscillates freely), `1` = critically damped.
1733
+ * Values `> 1` are overdamped. Must be `>= 0`. Ignored when `stiff` is `true`.
1734
+ * @defaultValue `1`
1735
+ */
1234
1736
  get damping(): number;
1235
1737
  set damping(value: number);
1738
+ /**
1739
+ * Maximum force (in Newtons) the constraint may apply per step.
1740
+ *
1741
+ * When the required force exceeds this value the constraint becomes slack.
1742
+ * If `breakUnderForce` is `true` the constraint breaks instead.
1743
+ * Must be `>= 0`. `Infinity` disables the limit.
1744
+ * @defaultValue `Infinity`
1745
+ */
1236
1746
  get maxForce(): number;
1237
1747
  set maxForce(value: number);
1748
+ /**
1749
+ * Maximum positional error (in pixels) allowed before breaking.
1750
+ *
1751
+ * Only meaningful when `breakUnderError` is `true`.
1752
+ * Must be `>= 0`. `Infinity` disables the limit.
1753
+ * @defaultValue `Infinity`
1754
+ */
1238
1755
  get maxError(): number;
1239
1756
  set maxError(value: number);
1757
+ /**
1758
+ * When `true`, the constraint breaks (fires a `BREAK` event) if the applied
1759
+ * force exceeds `maxForce` in a single step.
1760
+ * @defaultValue `false`
1761
+ */
1240
1762
  get breakUnderForce(): boolean;
1241
1763
  set breakUnderForce(value: boolean);
1764
+ /**
1765
+ * When `true`, the constraint breaks if the positional error exceeds `maxError`.
1766
+ * @defaultValue `false`
1767
+ */
1242
1768
  get breakUnderError(): boolean;
1243
1769
  set breakUnderError(value: boolean);
1770
+ /**
1771
+ * When `true` (default), the constraint is automatically removed from its space
1772
+ * when it breaks. Set to `false` to keep it in the space after breaking.
1773
+ * @defaultValue `true`
1774
+ */
1244
1775
  get removeOnBreak(): boolean;
1245
1776
  set removeOnBreak(value: boolean);
1777
+ /**
1778
+ * Whether the constraint's simulation component is currently sleeping.
1779
+ *
1780
+ * Only valid when the constraint is active and in a space — throws otherwise.
1781
+ */
1246
1782
  get isSleeping(): boolean;
1783
+ /**
1784
+ * Arbitrary user data attached to this constraint.
1785
+ * Lazily initialized to `{}` on first access.
1786
+ */
1247
1787
  get userData(): Record<string, unknown>;
1788
+ /**
1789
+ * The set of {@link CbType}s assigned to this constraint.
1790
+ * Used to filter which listeners respond to this constraint's events.
1791
+ */
1248
1792
  get cbTypes(): object;
1793
+ /**
1794
+ * The impulse applied by this constraint in the last simulation step.
1795
+ *
1796
+ * The shape of the returned {@link MatMN} depends on the constraint's degrees of
1797
+ * freedom (e.g., 1×1 for AngleJoint/MotorJoint, 2×1 for PivotJoint/LineJoint,
1798
+ * 3×1 for WeldJoint).
1799
+ */
1249
1800
  impulse(): MatMN | null;
1801
+ /**
1802
+ * The impulse applied to `body` by this constraint in the last simulation step,
1803
+ * expressed as a {@link Vec3} `(fx, fy, torque)`.
1804
+ *
1805
+ * @param body - Must be one of the bodies linked to this constraint.
1806
+ */
1250
1807
  bodyImpulse(_body: Body): Vec3 | null;
1808
+ /**
1809
+ * Invokes `fn` once for each distinct body linked to this constraint.
1810
+ *
1811
+ * @param fn - Function to call for each body.
1812
+ */
1251
1813
  visitBodies(_fn: (body: Body) => void): void;
1814
+ /**
1815
+ * Creates and returns a copy of this constraint with the same parameters.
1816
+ * The copy is not automatically added to a space.
1817
+ */
1252
1818
  copy(): Constraint;
1253
1819
  toString(): string;
1254
1820
  }
@@ -1554,77 +2120,275 @@ declare class Broadphase {
1554
2120
  }
1555
2121
 
1556
2122
  /**
1557
- * Interaction type filter for interaction listeners.
2123
+ * Enumeration of interaction categories used to filter {@link InteractionListener}
2124
+ * and {@link PreListener} callbacks.
1558
2125
  *
1559
- * - `COLLISION` — collision interactions only
1560
- * - `SENSOR` — sensor interactions only
1561
- * - `FLUID` — fluid interactions only
1562
- * - `ANY` — any interaction type
2126
+ * - `COLLISION` — physical collisions between solid shapes
2127
+ * - `SENSOR` — sensor (trigger) interactions where shapes overlap but don't resolve
2128
+ * - `FLUID` — fluid buoyancy/drag interactions
2129
+ * - `ANY` — all of the above
1563
2130
  *
1564
2131
  * Converted from nape-compiled.js lines 1785–1883.
1565
2132
  */
1566
2133
  declare class InteractionType {
1567
2134
  static __name__: string[];
1568
2135
  constructor();
2136
+ /** Physical collision between solid shapes (default for most shapes). */
1569
2137
  static get COLLISION(): InteractionType;
2138
+ /** Sensor/trigger overlap — shapes overlap but collision is not resolved. */
1570
2139
  static get SENSOR(): InteractionType;
2140
+ /** Fluid buoyancy/drag interaction between a fluid shape and a body. */
1571
2141
  static get FLUID(): InteractionType;
2142
+ /** Matches all interaction types (COLLISION, SENSOR, and FLUID). */
1572
2143
  static get ANY(): InteractionType;
1573
2144
  toString(): string;
1574
2145
  }
1575
2146
 
1576
2147
  /**
1577
- * The physics world. Add bodies and constraints, then call `step()` each frame.
1578
- *
1579
- * Fully modernized — uses ZPP_Space directly (extracted to TypeScript).
2148
+ * The physics world. Add bodies, shapes, and constraints, then call `step()` each frame to advance the simulation.
1580
2149
  */
1581
2150
  declare class Space {
1582
2151
  zpp_inner: ZPP_Space;
2152
+ /**
2153
+ * @param gravity - Initial gravity vector (default (0, 0)).
2154
+ * @param broadphase - Broadphase algorithm to use.
2155
+ */
1583
2156
  constructor(gravity?: Vec2, broadphase?: Broadphase);
1584
2157
  /** @internal */
1585
2158
  get _inner(): this;
1586
2159
  /** @internal */
1587
2160
  static _wrap(inner: NapeInner): Space;
2161
+ /** Arbitrary user data attached to this Space. */
1588
2162
  get userData(): Record<string, unknown>;
2163
+ /**
2164
+ * World gravity applied to all dynamic bodies each step. Live Vec2.
2165
+ * @throws If set to null or a disposed Vec2.
2166
+ */
1589
2167
  get gravity(): Vec2;
1590
2168
  set gravity(value: Vec2);
2169
+ /** The broadphase algorithm currently in use (SWEEP_AND_PRUNE or DYNAMIC_AABB_TREE). */
1591
2170
  get broadphase(): Broadphase;
2171
+ /** If true, contact points are sorted for determinism. Default: true. */
1592
2172
  get sortContacts(): boolean;
1593
2173
  set sortContacts(value: boolean);
2174
+ /**
2175
+ * Global angular drag coefficient applied to all bodies.
2176
+ * @throws If set to NaN.
2177
+ */
1594
2178
  get worldAngularDrag(): number;
1595
2179
  set worldAngularDrag(value: number);
2180
+ /**
2181
+ * Global linear drag coefficient applied to all bodies.
2182
+ * @throws If set to NaN.
2183
+ */
1596
2184
  get worldLinearDrag(): number;
1597
2185
  set worldLinearDrag(value: number);
2186
+ /** Read-only list of all Compound objects in this space. */
1598
2187
  get compounds(): object;
2188
+ /** Read-only list of all Body objects directly in this space. */
1599
2189
  get bodies(): object;
2190
+ /** Read-only list of bodies that are awake and actively simulated. */
1600
2191
  get liveBodies(): object;
2192
+ /** Read-only list of all Constraint objects in this space. */
1601
2193
  get constraints(): object;
2194
+ /** Read-only list of active (awake) constraints. */
1602
2195
  get liveConstraints(): object;
2196
+ /** The static world body that acts as an immovable anchor for constraints. */
1603
2197
  get world(): Body;
2198
+ /** Read-only list of all active collision/fluid arbiters. */
1604
2199
  get arbiters(): object;
2200
+ /** Read-only list of all event listeners registered to this space. */
1605
2201
  get listeners(): object;
2202
+ /** Number of `step()` calls made so far. */
1606
2203
  get timeStamp(): number;
2204
+ /** Cumulative time simulated (sum of all `deltaTime` values passed to `step()`). */
1607
2205
  get elapsedTime(): number;
2206
+ /**
2207
+ * Advance the simulation by `deltaTime` seconds.
2208
+ * `velocityIterations` and `positionIterations` control solver accuracy (default 10 each).
2209
+ * @param deltaTime - Time step in seconds; must be strictly positive and not NaN.
2210
+ * @param velocityIterations - Number of velocity solver iterations (minimum 1).
2211
+ * @param positionIterations - Number of position solver iterations (minimum 1).
2212
+ * @throws If `deltaTime` is NaN, non-positive, or any iteration count is less than 1.
2213
+ */
1608
2214
  step(deltaTime: number, velocityIterations?: number, positionIterations?: number): void;
2215
+ /**
2216
+ * Remove all bodies, constraints, and compounds from this space.
2217
+ * @throws If called during a `step()`.
2218
+ */
1609
2219
  clear(): void;
2220
+ /**
2221
+ * Call `lambda` for every body in the space, including those inside compounds.
2222
+ * @param lambda - Callback invoked with each Body.
2223
+ * @throws If `lambda` is null.
2224
+ */
1610
2225
  visitBodies(lambda: (body: Body) => void): void;
2226
+ /**
2227
+ * Call `lambda` for every constraint in the space, including those inside compounds.
2228
+ * @param lambda - Callback invoked with each Constraint.
2229
+ * @throws If `lambda` is null.
2230
+ */
1611
2231
  visitConstraints(lambda: (constraint: Constraint) => void): void;
2232
+ /**
2233
+ * Call `lambda` for every compound in the space (recursively).
2234
+ * @param lambda - Callback invoked with each Compound.
2235
+ * @throws If `lambda` is null.
2236
+ */
1612
2237
  visitCompounds(lambda: (compound: Compound) => void): void;
2238
+ /**
2239
+ * Determine the type of interaction between two shapes (COLLISION, FLUID, SENSOR, or null if they don't interact).
2240
+ * @param shape1 - The first shape; must belong to a Body.
2241
+ * @param shape2 - The second shape; must belong to a Body.
2242
+ * @returns The InteractionType, or null if the shapes would not interact.
2243
+ * @throws If either shape is null or not attached to a Body.
2244
+ */
1613
2245
  interactionType(shape1: Shape, shape2: Shape): InteractionType | null;
2246
+ /**
2247
+ * Return all shapes whose geometry contains the given world-space point.
2248
+ * @param point - The world-space point to test.
2249
+ * @param filter - Optional interaction filter to restrict results.
2250
+ * @param output - Optional existing ShapeList to accumulate results into.
2251
+ * @returns A ShapeList of matching shapes.
2252
+ * @throws If `point` is null or disposed.
2253
+ */
1614
2254
  shapesUnderPoint(point: Vec2, filter?: InteractionFilter | null, output?: object | null): object;
2255
+ /**
2256
+ * Return all bodies that have at least one shape containing the given world-space point.
2257
+ * @param point - The world-space point to test.
2258
+ * @param filter - Optional interaction filter to restrict results.
2259
+ * @param output - Optional existing BodyList to accumulate results into.
2260
+ * @returns A BodyList of matching bodies.
2261
+ * @throws If `point` is null or disposed.
2262
+ */
1615
2263
  bodiesUnderPoint(point: Vec2, filter?: InteractionFilter | null, output?: object | null): object;
2264
+ /**
2265
+ * Return all shapes that overlap with the given AABB.
2266
+ * @param aabb - The axis-aligned bounding box to test against.
2267
+ * @param containment - If true, only shapes fully contained within the AABB are returned.
2268
+ * @param strict - If true, exact shape geometry is tested; otherwise only AABBs are compared.
2269
+ * @param filter - Optional interaction filter to restrict results.
2270
+ * @param output - Optional existing ShapeList to accumulate results into.
2271
+ * @returns A ShapeList of matching shapes.
2272
+ * @throws If `aabb` is null or degenerate (zero width or height).
2273
+ */
1616
2274
  shapesInAABB(aabb: AABB, containment?: boolean, strict?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2275
+ /**
2276
+ * Return all bodies that have at least one shape overlapping the given AABB.
2277
+ * @param aabb - The axis-aligned bounding box to test against.
2278
+ * @param containment - If true, only shapes fully contained within the AABB count.
2279
+ * @param strict - If true, exact shape geometry is tested; otherwise only AABBs are compared.
2280
+ * @param filter - Optional interaction filter to restrict results.
2281
+ * @param output - Optional existing BodyList to accumulate results into.
2282
+ * @returns A BodyList of matching bodies.
2283
+ * @throws If `aabb` is null or degenerate (zero width or height).
2284
+ */
1617
2285
  bodiesInAABB(aabb: AABB, containment?: boolean, strict?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2286
+ /**
2287
+ * Return all shapes that overlap with a circle defined by `position` and `radius`.
2288
+ * @param position - World-space centre of the query circle.
2289
+ * @param radius - Radius of the query circle; must be strictly positive and not NaN.
2290
+ * @param containment - If true, only shapes fully contained within the circle are returned.
2291
+ * @param filter - Optional interaction filter to restrict results.
2292
+ * @param output - Optional existing ShapeList to accumulate results into.
2293
+ * @returns A ShapeList of matching shapes.
2294
+ * @throws If `position` is null/disposed, or `radius` is NaN or non-positive.
2295
+ */
1618
2296
  shapesInCircle(position: Vec2, radius: number, containment?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2297
+ /**
2298
+ * Return all bodies that have at least one shape overlapping a query circle.
2299
+ * @param position - World-space centre of the query circle.
2300
+ * @param radius - Radius of the query circle; must be strictly positive and not NaN.
2301
+ * @param containment - If true, only shapes fully contained within the circle count.
2302
+ * @param filter - Optional interaction filter to restrict results.
2303
+ * @param output - Optional existing BodyList to accumulate results into.
2304
+ * @returns A BodyList of matching bodies.
2305
+ * @throws If `position` is null/disposed, or `radius` is NaN or non-positive.
2306
+ */
1619
2307
  bodiesInCircle(position: Vec2, radius: number, containment?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2308
+ /**
2309
+ * Return all shapes in the space that overlap with `shape`.
2310
+ * @param shape - The query shape; must be attached to a Body.
2311
+ * @param containment - If true, only shapes fully contained within `shape` are returned.
2312
+ * @param filter - Optional interaction filter to restrict results.
2313
+ * @param output - Optional existing ShapeList to accumulate results into.
2314
+ * @returns A ShapeList of overlapping shapes.
2315
+ * @throws If `shape` is null, not attached to a Body, or is an invalid polygon.
2316
+ */
1620
2317
  shapesInShape(shape: Shape, containment?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2318
+ /**
2319
+ * Return all bodies in the space that have at least one shape overlapping `shape`.
2320
+ * @param shape - The query shape; must be attached to a Body.
2321
+ * @param containment - If true, only shapes fully contained within `shape` count.
2322
+ * @param filter - Optional interaction filter to restrict results.
2323
+ * @param output - Optional existing BodyList to accumulate results into.
2324
+ * @returns A BodyList of overlapping bodies.
2325
+ * @throws If `shape` is null, not attached to a Body, or is an invalid polygon.
2326
+ */
1621
2327
  bodiesInShape(shape: Shape, containment?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2328
+ /**
2329
+ * Return all shapes in the space that overlap with any shape attached to `body`.
2330
+ * Equivalent to calling `shapesInShape` for each of `body`'s shapes and merging results.
2331
+ * @param body - The body whose shapes are used as the query region.
2332
+ * @param filter - Optional interaction filter to restrict results.
2333
+ * @param output - Optional existing ShapeList to accumulate results into.
2334
+ * @returns A ShapeList of overlapping shapes.
2335
+ * @throws If `body` is null.
2336
+ */
1622
2337
  shapesInBody(body: Body, filter?: InteractionFilter | null, output?: object | null): object;
2338
+ /**
2339
+ * Return all bodies in the space that overlap with any shape attached to `body`.
2340
+ * Equivalent to calling `bodiesInShape` for each of `body`'s shapes and merging results.
2341
+ * @param body - The body whose shapes are used as the query region.
2342
+ * @param filter - Optional interaction filter to restrict results.
2343
+ * @param output - Optional existing BodyList to accumulate results into.
2344
+ * @returns A BodyList of overlapping bodies.
2345
+ * @throws If `body` is null.
2346
+ */
1623
2347
  bodiesInBody(body: Body, filter?: InteractionFilter | null, output?: object | null): object;
2348
+ /**
2349
+ * Sweep `shape` along its current velocity for `deltaTime` seconds and return the first hit.
2350
+ * @param shape - The shape to sweep; must belong to a Body.
2351
+ * @param deltaTime - Duration of the sweep; must be non-negative.
2352
+ * @param liveSweep - If true, other body velocities are considered during the sweep.
2353
+ * @param filter - Optional interaction filter to restrict results.
2354
+ * @returns The first RayResult hit, or null if nothing was struck.
2355
+ * @throws If `shape` is null, not attached to a Body, or `deltaTime` is negative/NaN.
2356
+ */
1624
2357
  convexCast(shape: Shape, deltaTime: number, liveSweep?: boolean, filter?: InteractionFilter | null): object | null;
2358
+ /**
2359
+ * Sweep `shape` along its current velocity for `deltaTime` seconds and return all hits.
2360
+ * @param shape - The shape to sweep; must belong to a Body.
2361
+ * @param deltaTime - Duration of the sweep; must be non-negative.
2362
+ * @param liveSweep - If true, other body velocities are considered during the sweep.
2363
+ * @param filter - Optional interaction filter to restrict results.
2364
+ * @param output - Optional existing RayResultList to accumulate results into.
2365
+ * @returns A RayResultList of all hits encountered during the sweep.
2366
+ * @throws If `shape` is null, not attached to a Body, or `deltaTime` is negative/NaN.
2367
+ */
1625
2368
  convexMultiCast(shape: Shape, deltaTime: number, liveSweep?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2369
+ /**
2370
+ * Cast a ray into the space and return the closest hit.
2371
+ * @param ray - The ray to cast.
2372
+ * @param inner - If true, shapes are tested from the inside as well (useful for concave queries).
2373
+ * @param filter - Optional interaction filter to restrict results.
2374
+ * @returns The closest RayResult, or null if nothing was hit.
2375
+ * @throws If `ray` is null.
2376
+ */
1626
2377
  rayCast(ray: Ray, inner?: boolean, filter?: InteractionFilter | null): object | null;
2378
+ /**
2379
+ * Cast a ray into the space and return all hits.
2380
+ * @param ray - The ray to cast.
2381
+ * @param inner - If true, shapes are tested from the inside as well.
2382
+ * @param filter - Optional interaction filter to restrict results.
2383
+ * @param output - Optional existing RayResultList to accumulate results into.
2384
+ * @returns A RayResultList of all shapes the ray intersected.
2385
+ * @throws If `ray` is null.
2386
+ */
1627
2387
  rayMultiCast(ray: Ray, inner?: boolean, filter?: InteractionFilter | null, output?: object | null): object;
2388
+ /**
2389
+ * Returns a brief string summary of this space.
2390
+ * @returns A string in the form `Space(bodies=N)`.
2391
+ */
1628
2392
  toString(): string;
1629
2393
  }
1630
2394
 
@@ -2083,107 +2847,350 @@ declare class GravMassMode {
2083
2847
  }
2084
2848
 
2085
2849
  /**
2086
- * A rigid body in the physics simulation.
2087
- *
2088
- * Fully modernized — all methods implemented directly using ZPP_Body.
2850
+ * A rigid body in the physics simulation. Add shapes to give it geometry, then add it to a `Space` to participate in simulation.
2089
2851
  */
2090
2852
  declare class Body extends Interactor {
2091
2853
  static __name__: string[];
2092
2854
  static __super__: typeof Interactor;
2093
2855
  /** Direct access to the extracted internal ZPP_Body. */
2094
2856
  zpp_inner: ZPP_Body;
2857
+ /** If true, this body is included in debug rendering. */
2095
2858
  debugDraw: boolean;
2859
+ /**
2860
+ * @param type - Body type (DYNAMIC by default).
2861
+ * @param position - Initial world-space position (defaults to origin).
2862
+ */
2096
2863
  constructor(type?: BodyType, position?: Vec2);
2097
2864
  /** @internal */
2098
2865
  static _wrap(inner: NapeInner): Body;
2866
+ /** The body type: DYNAMIC, STATIC, or KINEMATIC. Cannot be changed mid-step. */
2099
2867
  get type(): BodyType;
2100
2868
  set type(value: BodyType);
2869
+ /** Return true if this body is static. */
2101
2870
  isStatic(): boolean;
2871
+ /** Return true if this body is dynamic. */
2102
2872
  isDynamic(): boolean;
2873
+ /** Return true if this body is kinematic. */
2103
2874
  isKinematic(): boolean;
2875
+ /** World-space position of the body's origin. Live Vec2 — mutating it moves the body. */
2104
2876
  get position(): Vec2;
2105
2877
  set position(value: Vec2);
2878
+ /**
2879
+ * Rotation of the body in radians.
2880
+ * @throws If set on a static body that is already in a space.
2881
+ */
2106
2882
  get rotation(): number;
2107
2883
  set rotation(value: number);
2884
+ /** Linear velocity in world space (units/s). Live Vec2. Static bodies cannot have velocity. */
2108
2885
  get velocity(): Vec2;
2109
2886
  set velocity(value: Vec2);
2887
+ /** Angular velocity in radians per second. */
2110
2888
  get angularVel(): number;
2111
2889
  set angularVel(value: number);
2890
+ /** Desired velocity for kinematic bodies; the engine tries to match this each step. */
2112
2891
  get kinematicVel(): Vec2;
2113
2892
  set kinematicVel(value: Vec2);
2893
+ /** Desired angular velocity for kinematic bodies. */
2114
2894
  get kinAngVel(): number;
2115
2895
  set kinAngVel(value: number);
2896
+ /** Surface velocity used in friction calculations. */
2116
2897
  get surfaceVel(): Vec2;
2117
2898
  set surfaceVel(value: Vec2);
2899
+ /** Accumulated force applied to this body for the current step (cleared after each step). */
2118
2900
  get force(): Vec2;
2119
2901
  set force(value: Vec2);
2902
+ /** Accumulated torque applied to this body for the current step (only for DYNAMIC bodies). */
2120
2903
  get torque(): number;
2121
2904
  set torque(value: number);
2905
+ /**
2906
+ * Mass in kg. Must be finite and > 0. Setting switches massMode to FIXED.
2907
+ * @throws If the body is the world body, or if no shapes are present in DEFAULT mass mode.
2908
+ */
2122
2909
  get mass(): number;
2123
2910
  set mass(value: number);
2911
+ /**
2912
+ * Moment of inertia. Must be finite and > 0. Setting switches inertiaMode to FIXED.
2913
+ * @throws If the body is the world body, or if no shapes are present in DEFAULT inertia mode.
2914
+ */
2124
2915
  get inertia(): number;
2125
2916
  set inertia(value: number);
2917
+ /** Effective mass used by the constraint solver (accounts for allowMovement). */
2126
2918
  get constraintMass(): number;
2919
+ /** Effective inertia used by the constraint solver (accounts for allowRotation). */
2127
2920
  get constraintInertia(): number;
2921
+ /** Gravitational mass. Defaults to the same as `mass`. */
2128
2922
  get gravMass(): number;
2129
2923
  set gravMass(value: number);
2924
+ /** Scale factor applied to gravMass relative to the dynamic mass. */
2130
2925
  get gravMassScale(): number;
2131
2926
  set gravMassScale(value: number);
2927
+ /** If true, continuous collision detection (CCD) is enabled for this body. */
2132
2928
  get isBullet(): boolean;
2133
2929
  set isBullet(value: boolean);
2930
+ /** If true, CCD is disabled even if `isBullet` is set. */
2134
2931
  get disableCCD(): boolean;
2135
2932
  set disableCCD(value: boolean);
2933
+ /** If false, translational motion is frozen (infinite effective mass). */
2136
2934
  get allowMovement(): boolean;
2137
2935
  set allowMovement(value: boolean);
2936
+ /** If false, rotational motion is frozen (infinite effective inertia). */
2138
2937
  get allowRotation(): boolean;
2139
2938
  set allowRotation(value: boolean);
2939
+ /**
2940
+ * True if the body is currently sleeping.
2941
+ * @throws If the body is not in a Space.
2942
+ */
2140
2943
  get isSleeping(): boolean;
2944
+ /** List of shapes attached to this body. */
2141
2945
  get shapes(): NapeList<Shape>;
2946
+ /** The Space this body belongs to. Setting adds/removes it from the space. */
2142
2947
  get space(): Space;
2143
2948
  set space(value: Space | null);
2949
+ /** The Compound this body belongs to, or null. */
2144
2950
  get compound(): Compound | null;
2145
2951
  set compound(value: Compound | null);
2952
+ /**
2953
+ * World-space AABB enclosing all shapes.
2954
+ * @throws If this is the world body.
2955
+ */
2146
2956
  get bounds(): AABB;
2957
+ /** Constraint-solved velocity (read-only view used by the solver). */
2147
2958
  get constraintVelocity(): Vec2;
2959
+ /**
2960
+ * Local-space centre of mass (read-only, lazy-computed from shapes).
2961
+ * @throws If this is the world body.
2962
+ */
2148
2963
  get localCOM(): Vec2;
2964
+ /**
2965
+ * World-space centre of mass (read-only, lazy-computed).
2966
+ * @throws If this is the world body.
2967
+ */
2149
2968
  get worldCOM(): Vec2;
2969
+ /** Controls how mass is computed: DEFAULT (from shapes) or FIXED (manually set). */
2150
2970
  get massMode(): MassMode;
2151
2971
  set massMode(value: MassMode);
2972
+ /** Controls how inertia is computed: DEFAULT or FIXED. */
2152
2973
  get inertiaMode(): InertiaMode;
2153
2974
  set inertiaMode(value: InertiaMode);
2975
+ /** Controls gravitational mass: DEFAULT, FIXED, or SCALED. */
2154
2976
  get gravMassMode(): GravMassMode;
2155
2977
  set gravMassMode(value: GravMassMode);
2978
+ /**
2979
+ * Create a deep copy of this body (shapes, mass properties, etc.).
2980
+ * @returns A new Body with identical configuration.
2981
+ * @throws If this is the world body.
2982
+ */
2156
2983
  copy(): Body;
2984
+ /**
2985
+ * String identifier like `(dynamic)#42`.
2986
+ * @returns A human-readable description of this body.
2987
+ */
2157
2988
  toString(): string;
2989
+ /**
2990
+ * Manually integrate the body's position and rotation by `deltaTime` seconds (outside of `Space.step`).
2991
+ * @param deltaTime - Time in seconds to integrate over.
2992
+ * @returns `this` for chaining.
2993
+ * @throws If `deltaTime` is NaN.
2994
+ */
2158
2995
  integrate(deltaTime: number): Body;
2996
+ /**
2997
+ * Transform a point from local body space to world space.
2998
+ * @param point - The point in local space.
2999
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
3000
+ * @returns The transformed point in world space.
3001
+ */
2159
3002
  localPointToWorld(point: Vec2, weak?: boolean): Vec2;
3003
+ /**
3004
+ * Transform a point from world space to local body space.
3005
+ * @param point - The point in world space.
3006
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
3007
+ * @returns The transformed point in local space.
3008
+ */
2160
3009
  worldPointToLocal(point: Vec2, weak?: boolean): Vec2;
3010
+ /**
3011
+ * Rotate a vector from local body space to world space (no translation).
3012
+ * @param vector - The vector in local space.
3013
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
3014
+ * @returns The rotated vector in world space.
3015
+ */
2161
3016
  localVectorToWorld(vector: Vec2, weak?: boolean): Vec2;
3017
+ /**
3018
+ * Rotate a vector from world space to local body space (no translation).
3019
+ * @param vector - The vector in world space.
3020
+ * @param weak - If true, the returned Vec2 is a weak (pooled) reference.
3021
+ * @returns The rotated vector in local space.
3022
+ */
2162
3023
  worldVectorToLocal(vector: Vec2, weak?: boolean): Vec2;
3024
+ /**
3025
+ * Apply a linear (and optionally angular) impulse to the body.
3026
+ * If `pos` is given, it creates a torque about the body's centre.
3027
+ * If `sleepable` is true, sleeping bodies are not woken.
3028
+ * @param impulse - The linear impulse vector (world space).
3029
+ * @param pos - Optional world-space point of application.
3030
+ * @param sleepable - If true, the body will not be woken if sleeping.
3031
+ * @returns `this` for chaining.
3032
+ */
2163
3033
  applyImpulse(impulse: Vec2, pos?: Vec2, sleepable?: boolean): Body;
3034
+ /**
3035
+ * Apply a direct angular impulse (change in angular velocity × inertia).
3036
+ * @param impulse - The angular impulse magnitude.
3037
+ * @param sleepable - If true, the body will not be woken if sleeping.
3038
+ * @returns `this` for chaining.
3039
+ */
2164
3040
  applyAngularImpulse(impulse: number, sleepable?: boolean): Body;
3041
+ /**
3042
+ * Set linear and angular velocity so the body reaches the given target pose in `deltaTime` seconds.
3043
+ * Useful for kinematic or manually driven bodies.
3044
+ * @param targetPosition - Desired world-space position.
3045
+ * @param targetRotation - Desired rotation in radians.
3046
+ * @param deltaTime - Time in seconds over which to reach the target.
3047
+ * @returns `this` for chaining.
3048
+ * @throws If `targetPosition` is null or `deltaTime` is zero.
3049
+ */
2165
3050
  setVelocityFromTarget(targetPosition: Vec2, targetRotation: number, deltaTime: number): Body;
3051
+ /**
3052
+ * Translate all shapes attached to this body in local space by `translation`.
3053
+ * @param translation - Offset vector in local space.
3054
+ * @returns `this` for chaining.
3055
+ */
2166
3056
  translateShapes(translation: Vec2): Body;
3057
+ /**
3058
+ * Rotate all shapes attached to this body in local space by `angle` radians.
3059
+ * @param angle - Rotation in radians.
3060
+ * @returns `this` for chaining.
3061
+ */
2167
3062
  rotateShapes(angle: number): Body;
3063
+ /**
3064
+ * Scale all shapes attached to this body in local space.
3065
+ * @param scaleX - Horizontal scale factor.
3066
+ * @param scaleY - Vertical scale factor.
3067
+ * @returns `this` for chaining.
3068
+ */
2168
3069
  scaleShapes(scaleX: number, scaleY: number): Body;
3070
+ /**
3071
+ * Apply an affine transform matrix to all shapes in local space.
3072
+ * @param matrix - The 2D affine transformation matrix.
3073
+ * @returns `this` for chaining.
3074
+ */
2169
3075
  transformShapes(matrix: Mat23): Body;
3076
+ /**
3077
+ * Translate all shapes and adjust the body position so the local centre of mass coincides with the body origin.
3078
+ * @returns `this` for chaining.
3079
+ * @throws If the body has no shapes.
3080
+ */
2170
3081
  align(): Body;
3082
+ /**
3083
+ * Rotate the body about a world-space pivot point by `angle` radians.
3084
+ * Moves the body's position and increments its rotation.
3085
+ * @param centre - World-space pivot point.
3086
+ * @param angle - Rotation in radians.
3087
+ * @returns `this` for chaining.
3088
+ * @throws If `centre` is null or `angle` is NaN.
3089
+ */
2171
3090
  rotate(centre: Vec2, angle: number): Body;
3091
+ /**
3092
+ * Set the same `Material` on every shape attached to this body.
3093
+ * @param material - The material to apply.
3094
+ * @returns `this` for chaining.
3095
+ */
2172
3096
  setShapeMaterials(material: Material): Body;
3097
+ /**
3098
+ * Set the same `InteractionFilter` on every shape attached to this body.
3099
+ * @param filter - The interaction filter to apply.
3100
+ * @returns `this` for chaining.
3101
+ */
2173
3102
  setShapeFilters(filter: InteractionFilter): Body;
3103
+ /**
3104
+ * Set the same `FluidProperties` on every shape attached to this body.
3105
+ * @param fluidProperties - The fluid properties to apply.
3106
+ * @returns `this` for chaining.
3107
+ */
2174
3108
  setShapeFluidProperties(fluidProperties: FluidProperties): Body;
3109
+ /**
3110
+ * Test whether a world-space point lies inside any shape attached to this body.
3111
+ * @param point - The point to test in world space.
3112
+ * @returns True if the point is inside at least one shape.
3113
+ */
2175
3114
  contains(point: Vec2): boolean;
3115
+ /**
3116
+ * Return the set of bodies connected to this body via constraints.
3117
+ * @param depth - Maximum traversal depth (-1 means unlimited).
3118
+ * @param output - Optional existing list to accumulate results into.
3119
+ * @returns A BodyList of connected bodies.
3120
+ */
2176
3121
  connectedBodies(depth?: number, output?: object | null): object;
3122
+ /**
3123
+ * Return the set of bodies currently interacting with this body via arbiters.
3124
+ * @param type - Filter by interaction type (COLLISION, FLUID, SENSOR), or null for all.
3125
+ * @param _depth - Unused; reserved for future use.
3126
+ * @param output - Optional existing list to accumulate results into.
3127
+ * @returns A BodyList of interacting bodies.
3128
+ */
2177
3129
  interactingBodies(type?: InteractionType | null, _depth?: number, output?: object | null): object;
3130
+ /**
3131
+ * Sum of normal (penetration-resolving) impulses received from collision arbiters this step.
3132
+ * @param body - If provided, only arbiters shared with `body` are summed.
3133
+ * @param freshOnly - If true, only newly created arbiters are considered.
3134
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3135
+ */
2178
3136
  normalImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
3137
+ /**
3138
+ * Sum of tangent (friction) impulses received from collision arbiters this step.
3139
+ * @param body - If provided, only arbiters shared with `body` are summed.
3140
+ * @param freshOnly - If true, only newly created arbiters are considered.
3141
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3142
+ */
2179
3143
  tangentImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
3144
+ /**
3145
+ * Sum of total contact impulses (normal + tangent) from collision arbiters this step.
3146
+ * @param body - If provided, only arbiters shared with `body` are summed.
3147
+ * @param freshOnly - If true, only newly created arbiters are considered.
3148
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3149
+ */
2180
3150
  totalContactsImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
3151
+ /**
3152
+ * Sum of rolling (angular friction) impulses from collision arbiters this step.
3153
+ * @param body - If provided, only arbiters shared with `body` are summed.
3154
+ * @param freshOnly - If true, only newly created arbiters are considered.
3155
+ * @returns The total rolling impulse scalar.
3156
+ */
2181
3157
  rollingImpulse(body?: Body | null, freshOnly?: boolean): number;
3158
+ /**
3159
+ * Sum of buoyancy impulses received from fluid arbiters this step.
3160
+ * @param body - If provided, only arbiters shared with `body` are summed.
3161
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3162
+ */
2182
3163
  buoyancyImpulse(body?: Body | null): Vec3;
3164
+ /**
3165
+ * Sum of fluid drag impulses received from fluid arbiters this step.
3166
+ * @param body - If provided, only arbiters shared with `body` are summed.
3167
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3168
+ */
2183
3169
  dragImpulse(body?: Body | null): Vec3;
3170
+ /**
3171
+ * Sum of total fluid impulses (buoyancy + drag) from fluid arbiters this step.
3172
+ * @param body - If provided, only arbiters shared with `body` are summed.
3173
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3174
+ */
2184
3175
  totalFluidImpulse(body?: Body | null): Vec3;
3176
+ /**
3177
+ * Sum of impulses applied to this body by all attached constraints this step.
3178
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3179
+ */
2185
3180
  constraintsImpulse(): Vec3;
3181
+ /**
3182
+ * Sum of all impulses (contacts + constraints) applied to this body this step, excluding sensor arbiters.
3183
+ * @param body - If provided, only arbiters shared with `body` are summed.
3184
+ * @param freshOnly - If true, only newly created contact arbiters are considered.
3185
+ * @returns A Vec3 where x/y are the linear component and z is the angular component.
3186
+ */
2186
3187
  totalImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
3188
+ /**
3189
+ * Compute a heuristic crush factor indicating how strongly this body is being compressed from multiple directions.
3190
+ * A value near zero means balanced forces; larger values indicate compression.
3191
+ * @returns The crush factor (dimensionless).
3192
+ * @throws If the body is not in a Space.
3193
+ */
2187
3194
  crushFactor(): number;
2188
3195
  private _getArbiters;
2189
3196
  private _getConstraints;
@@ -2207,48 +3214,99 @@ declare class ShapeType {
2207
3214
  }
2208
3215
 
2209
3216
  /**
2210
- * Base class for physics shapes (Circle, Polygon).
2211
- *
2212
- * Fully modernized — all getters/setters access the ZPP_Shape inner directly.
3217
+ * Base class for physics shapes (Circle, Polygon). Never instantiated directly — use
3218
+ * `new Circle(...)` or `Polygon.box(...)` etc.
2213
3219
  */
2214
3220
  declare class Shape extends Interactor {
2215
3221
  /** @internal – shapes are created via Circle or Polygon constructors. */
2216
3222
  protected constructor();
2217
3223
  /** @internal */
2218
3224
  static _wrap(inner: NapeInner): Shape;
3225
+ /** The shape type: CIRCLE or POLYGON. */
2219
3226
  get type(): ShapeType;
3227
+ /** Returns true if this is a Circle shape. */
2220
3228
  isCircle(): boolean;
3229
+ /** Returns true if this is a Polygon shape. */
2221
3230
  isPolygon(): boolean;
3231
+ /**
3232
+ * The Body this shape belongs to. Setting moves the shape between bodies.
3233
+ */
2222
3234
  get body(): Body;
2223
3235
  set body(value: Body | null);
3236
+ /** Cast to Circle, or null if this is not a circle. */
2224
3237
  get castCircle(): Shape | null;
3238
+ /** Cast to Polygon, or null if this is not a polygon. */
2225
3239
  get castPolygon(): Shape | null;
3240
+ /** World-space centre of mass of this shape (read-only, lazy-computed). */
2226
3241
  get worldCOM(): Vec2;
3242
+ /**
3243
+ * Local-space centre of mass. Can be set to override the default shape centroid.
3244
+ */
2227
3245
  get localCOM(): Vec2;
2228
3246
  set localCOM(value: Vec2);
3247
+ /** Cross-sectional area of this shape. */
2229
3248
  get area(): number;
3249
+ /** Contribution to moment of inertia (about local centroid, unit density). */
2230
3250
  get inertia(): number;
3251
+ /** Angular drag coefficient for this shape. */
2231
3252
  get angDrag(): number;
3253
+ /** The Material assigned to this shape (controls friction, elasticity, density). */
2232
3254
  get material(): Material;
2233
3255
  set material(value: Material);
3256
+ /** The InteractionFilter controlling which shapes interact with this one. */
2234
3257
  get filter(): InteractionFilter;
2235
3258
  set filter(value: InteractionFilter);
3259
+ /** Fluid simulation properties for this shape. Auto-created on first access. */
2236
3260
  get fluidProperties(): FluidProperties;
2237
3261
  set fluidProperties(value: FluidProperties);
2238
- /** Callback types assigned to this shape. */
3262
+ /** Set of callback types registered on this shape for event dispatch. */
2239
3263
  get cbTypes(): CbTypeSet;
3264
+ /** If true, this shape participates in fluid interaction. */
2240
3265
  get fluidEnabled(): boolean;
2241
3266
  set fluidEnabled(value: boolean);
3267
+ /** If true, this shape acts as a sensor (no physical response, only callbacks). */
2242
3268
  get sensorEnabled(): boolean;
2243
3269
  set sensorEnabled(value: boolean);
3270
+ /** World-space AABB of this shape (updated each step). */
2244
3271
  get bounds(): AABB;
3272
+ /**
3273
+ * Translate the shape's local vertices by the given vector (in-place).
3274
+ * @param translation - The displacement vector to apply.
3275
+ * @returns `this` for chaining.
3276
+ */
2245
3277
  translate(translation: Vec2): Shape;
3278
+ /**
3279
+ * Scale the shape's local geometry. Circles require uniform scaling.
3280
+ * @param scaleX - Horizontal scale factor (must be non-zero).
3281
+ * @param scaleY - Vertical scale factor (must be non-zero).
3282
+ * @returns `this` for chaining.
3283
+ */
2246
3284
  scale(scaleX: number, scaleY: number): Shape;
3285
+ /**
3286
+ * Rotate the shape's local vertices by `angle` radians.
3287
+ * @param angle - Rotation in radians.
3288
+ * @returns `this` for chaining.
3289
+ */
2247
3290
  rotate(angle: number): Shape;
3291
+ /**
3292
+ * Apply a Mat23 affine transform to the shape's local geometry.
3293
+ * @param matrix - The transformation matrix (must be non-singular; Circles require equiorthogonal).
3294
+ * @returns `this` for chaining.
3295
+ */
2248
3296
  transform(matrix: {
2249
3297
  _inner: NapeInner;
2250
3298
  }): Shape;
3299
+ /**
3300
+ * Return true if the given world-space point lies inside this shape.
3301
+ * Requires the shape to be attached to a Body.
3302
+ * @param point - The world-space point to test.
3303
+ * @returns True if the point is inside this shape.
3304
+ */
2251
3305
  contains(point: Vec2): boolean;
3306
+ /**
3307
+ * Create a deep copy of this shape with the same type, geometry, material, and filter.
3308
+ * @returns A new Shape instance independent of this one.
3309
+ */
2252
3310
  copy(): Shape;
2253
3311
  toString(): string;
2254
3312
  /** @internal */ get_type(): ShapeType;
@@ -2439,20 +3497,24 @@ declare class ZPP_Circle {
2439
3497
  }
2440
3498
 
2441
3499
  /**
2442
- * A circular physics shape.
2443
- *
2444
- * Fully modernized — constructor and radius getter/setter use ZPP_Circle
2445
- * directly. Shape-level properties still delegate through compiled Shape
2446
- * prototype methods (copied to Circle.prototype at module load time).
3500
+ * A circular physics shape. The simplest and most performant collision shape.
2447
3501
  */
2448
3502
  declare class Circle extends Shape {
2449
3503
  static __name__: string[];
2450
3504
  static __super__: any;
2451
3505
  /** Direct access to the extracted internal ZPP_Circle. */
2452
3506
  zpp_inner_zn: ZPP_Circle;
3507
+ /**
3508
+ * Create a circle with the given radius and optional local centre-of-mass offset.
3509
+ * @param radius - Circle radius (must be > 0).
3510
+ * @param localCOM - Local centre offset (defaults to origin).
3511
+ * @param material - Material to assign (uses default if omitted).
3512
+ * @param filter - InteractionFilter to assign (uses default if omitted).
3513
+ */
2453
3514
  constructor(radius?: number, localCOM?: Vec2, material?: Material, filter?: InteractionFilter);
2454
3515
  /** @internal */
2455
3516
  static _wrap(inner: NapeInner): Circle;
3517
+ /** The circle's radius. Must be > 0. */
2456
3518
  get radius(): number;
2457
3519
  set radius(value: number);
2458
3520
  }
@@ -2574,28 +3636,61 @@ declare class ZPP_Polygon {
2574
3636
 
2575
3637
  /**
2576
3638
  * A convex polygon physics shape.
2577
- *
2578
- * Fully modernized — uses ZPP_Polygon directly (extracted to TypeScript).
2579
- * Use the static helper methods (`box`, `rect`, `regular`) for common shapes.
2580
3639
  */
2581
3640
  declare class Polygon extends Shape {
2582
3641
  static __name__: string[];
2583
3642
  static __super__: any;
2584
3643
  /** Direct access to the extracted internal ZPP_Polygon. */
2585
3644
  zpp_inner_zn: ZPP_Polygon;
3645
+ /**
3646
+ * Create a Polygon from a list of Vec2 vertices. Vertices must form a convex polygon
3647
+ * in counter-clockwise order.
3648
+ * @param localVerts - Vertices as `Array<Vec2>`, `Vec2List`, or `GeomPoly`.
3649
+ * @param material - Material to assign (uses default if omitted).
3650
+ * @param filter - InteractionFilter to assign (uses default if omitted).
3651
+ */
2586
3652
  constructor(localVerts?: Vec2[] | any, material?: Material, filter?: InteractionFilter);
2587
3653
  /** @internal */
2588
3654
  static _wrap(inner: NapeInner): Polygon;
3655
+ /**
3656
+ * Create an axis-aligned rectangle at the given position.
3657
+ * @param x - Left edge x coordinate.
3658
+ * @param y - Top edge y coordinate.
3659
+ * @param width - Rectangle width.
3660
+ * @param height - Rectangle height.
3661
+ * @param weak - If true, returned Vec2s are marked weak and will be auto-disposed.
3662
+ * @returns Array of four Vec2 corner vertices.
3663
+ */
2589
3664
  static rect(x: number, y: number, width: number, height: number, weak?: boolean): Vec2[];
3665
+ /**
3666
+ * Create an axis-aligned rectangular polygon centred at the origin.
3667
+ * @param width - Rectangle width.
3668
+ * @param height - Rectangle height (defaults to `width` for a square).
3669
+ * @param weak - If true, returned Vec2s are marked weak and will be auto-disposed.
3670
+ * @returns Array of four Vec2 corner vertices.
3671
+ */
2590
3672
  static box(width: number, height?: number, weak?: boolean): Vec2[];
3673
+ /**
3674
+ * Create a regular polygon (or ellipse approximation) centred at the origin.
3675
+ * @param xRadius - Horizontal radius of the circumscribed ellipse.
3676
+ * @param yRadius - Vertical radius of the circumscribed ellipse.
3677
+ * @param edgeCount - Number of sides (must be >= 3).
3678
+ * @param angleOffset - Rotation offset in radians applied to all vertices (default 0).
3679
+ * @param weak - If true, returned Vec2s are marked weak and will be auto-disposed.
3680
+ * @returns Array of `edgeCount` Vec2 vertices.
3681
+ */
2591
3682
  static regular(xRadius: number, yRadius: number, edgeCount: number, angleOffset?: number, weak?: boolean): Vec2[];
2592
- /** Read-only list of local-space vertices. */
3683
+ /** The list of local-space vertices defining this polygon's shape. */
2593
3684
  get localVerts(): any;
2594
- /** Read-only list of world-space vertices (computed after stepping). */
3685
+ /** World-space vertices of this polygon, updated each simulation step. */
2595
3686
  get worldVerts(): any;
2596
- /** Read-only edge list. */
3687
+ /** The list of edges derived from this polygon's vertices. */
2597
3688
  get edges(): any;
2598
- /** Validate the polygon geometry. */
3689
+ /**
3690
+ * Validate the polygon geometry and return a string describing any issues, or
3691
+ * `"valid"` if the polygon is well-formed.
3692
+ * @returns A validation result string from the underlying ZPP_Polygon.
3693
+ */
2599
3694
  validity(): any;
2600
3695
  /** @internal */ get_localVerts(): any;
2601
3696
  /** @internal */ get_worldVerts(): any;
@@ -2792,10 +3887,14 @@ declare class ZPP_Arbiter {
2792
3887
  }
2793
3888
 
2794
3889
  /**
2795
- * A collision arbiter between two shapes in contact.
3890
+ * An arbiter representing a physical collision between two solid shapes.
2796
3891
  *
2797
- * Provides access to contact points, collision normal, friction, elasticity,
2798
- * and impulse information. Some properties are mutable only in pre-handlers.
3892
+ * Provides access to contact points, collision normal, friction coefficients,
3893
+ * elasticity, and impulse data. Properties marked _mutable in pre-handler_ can
3894
+ * only be set within a {@link PreListener} handler.
3895
+ *
3896
+ * Obtain via {@link Arbiter.collisionArbiter} or by casting from a callback's
3897
+ * arbiter list.
2799
3898
  *
2800
3899
  * Fully modernized — uses extracted ZPP_ColArbiter directly.
2801
3900
  */
@@ -2803,8 +3902,15 @@ declare class CollisionArbiter extends Arbiter {
2803
3902
  static __name__: string[];
2804
3903
  static __super__: typeof Arbiter;
2805
3904
  constructor();
3905
+ /**
3906
+ * The list of active contact points between the two shapes.
3907
+ * Contains 1 or 2 {@link Contact} objects depending on the collision geometry.
3908
+ */
2806
3909
  get contacts(): object;
2807
- /** Collision normal vector. */
3910
+ /**
3911
+ * Collision normal vector pointing from `shape1` toward `shape2`.
3912
+ * Read-only; available after the arbiter is active.
3913
+ */
2808
3914
  get normal(): Vec2;
2809
3915
  /** Sum of the radii of the two shapes at the collision point. */
2810
3916
  get radius(): number;
@@ -2812,29 +3918,57 @@ declare class CollisionArbiter extends Arbiter {
2812
3918
  get referenceEdge1(): Edge | null;
2813
3919
  /** Reference edge of shape2 (if polygon), or null. */
2814
3920
  get referenceEdge2(): Edge | null;
2815
- /** Coefficient of restitution (elasticity). Mutable in pre-handler only. */
3921
+ /**
3922
+ * Coefficient of restitution (bounciness).
3923
+ *
3924
+ * Combined from the two shapes' `elasticity` values. Can be overridden
3925
+ * inside a pre-handler. Must be `>= 0`.
3926
+ *
3927
+ * _Mutable in pre-handler only._
3928
+ */
2816
3929
  get elasticity(): number;
2817
3930
  set elasticity(value: number);
2818
- /** Dynamic friction coefficient. Mutable in pre-handler only. */
3931
+ /**
3932
+ * Dynamic (kinetic) friction coefficient — applied when the contact is sliding.
3933
+ * Combined from the two shapes' material values. _Mutable in pre-handler only._
3934
+ */
2819
3935
  get dynamicFriction(): number;
2820
3936
  set dynamicFriction(value: number);
2821
- /** Static friction coefficient. Mutable in pre-handler only. */
3937
+ /**
3938
+ * Static friction coefficient — applied when the contact is at rest.
3939
+ * Combined from the two shapes' material values. _Mutable in pre-handler only._
3940
+ */
2822
3941
  get staticFriction(): number;
2823
3942
  set staticFriction(value: number);
2824
- /** Rolling friction coefficient. Mutable in pre-handler only. */
3943
+ /**
3944
+ * Rolling friction coefficient — resists rolling motion.
3945
+ * Combined from the two shapes' material values. _Mutable in pre-handler only._
3946
+ */
2825
3947
  get rollingFriction(): number;
2826
3948
  set rollingFriction(value: number);
2827
3949
  /** Whether the first contact point lies on a polygon vertex (poly-circle only). */
2828
3950
  firstVertex(): boolean;
2829
3951
  /** Whether the second contact point lies on a polygon vertex (poly-circle only). */
2830
3952
  secondVertex(): boolean;
2831
- /** Normal impulse accumulated across all contacts. */
3953
+ /**
3954
+ * Impulse applied in the normal (collision) direction, summed over all contacts.
3955
+ * @param body - One of the two bodies, or `null` for the combined value.
3956
+ * @param freshOnly - Only include new contact points. Default `false`.
3957
+ */
2832
3958
  normalImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
2833
- /** Tangent (friction) impulse accumulated across all contacts. */
3959
+ /**
3960
+ * Friction impulse applied in the tangent direction, summed over all contacts.
3961
+ * @param body - One of the two bodies, or `null` for the combined value.
3962
+ * @param freshOnly - Only include new contact points. Default `false`.
3963
+ */
2834
3964
  tangentImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
2835
3965
  /** Total impulse (normal + tangent + rolling) accumulated across all contacts. */
2836
3966
  totalImpulse(body?: Body | null, freshOnly?: boolean): Vec3;
2837
- /** Rolling impulse for this collision. */
3967
+ /**
3968
+ * Rolling impulse applied by this collision.
3969
+ * @param body - One of the two bodies, or `null` for the combined value.
3970
+ * @param freshOnly - Only include new contact points. Default `false`.
3971
+ */
2838
3972
  rollingImpulse(body?: Body | null, freshOnly?: boolean): number;
2839
3973
  /** @internal Throw if not in pre-handler mutable window. */
2840
3974
  private _mutableCheck;
@@ -2843,10 +3977,13 @@ declare class CollisionArbiter extends Arbiter {
2843
3977
  }
2844
3978
 
2845
3979
  /**
2846
- * A fluid arbiter between two shapes with fluid interaction.
3980
+ * An arbiter representing a fluid interaction between a fluid shape and a body.
3981
+ *
3982
+ * Provides access to buoyancy and drag impulses, the overlap area, and the
3983
+ * centre of overlap. Properties marked _mutable in pre-handler_ can only be
3984
+ * set within a {@link PreListener} handler.
2847
3985
  *
2848
- * Provides access to buoyancy/drag impulses, overlap area, and position.
2849
- * Some properties are mutable only in pre-handlers.
3986
+ * Obtain via {@link Arbiter.fluidArbiter} or by casting from a callback arbiter.
2850
3987
  *
2851
3988
  * Fully modernized — uses extracted ZPP_FluidArbiter directly.
2852
3989
  */
@@ -2854,45 +3991,76 @@ declare class FluidArbiter extends Arbiter {
2854
3991
  static __name__: string[];
2855
3992
  static __super__: typeof Arbiter;
2856
3993
  constructor();
2857
- /** Centre of the overlap region. Mutable in pre-handler only. */
3994
+ /**
3995
+ * Centre of the overlap region between the fluid and the body shape.
3996
+ * _Mutable in pre-handler only._
3997
+ */
2858
3998
  get position(): Vec2;
2859
3999
  set position(value: Vec2);
2860
- /** Area of the overlap region. Mutable in pre-handler only. */
4000
+ /**
4001
+ * Area of the overlap region in pixels². Used to compute buoyancy force.
4002
+ * Must be strictly positive and finite.
4003
+ * _Mutable in pre-handler only._
4004
+ */
2861
4005
  get overlap(): number;
2862
4006
  set overlap(value: number);
2863
- /** Buoyancy impulse applied by this fluid arbiter. */
4007
+ /**
4008
+ * Buoyancy impulse applied in the last step as `(fx, fy, torque)`.
4009
+ * @param body - One of the two bodies, or `null` for the combined value.
4010
+ */
2864
4011
  buoyancyImpulse(body?: Body | null): Vec3;
2865
- /** Drag impulse applied by this fluid arbiter. */
4012
+ /**
4013
+ * Linear and angular drag impulse applied in the last step as `(fx, fy, torque)`.
4014
+ * @param body - One of the two bodies, or `null` for the combined value.
4015
+ */
2866
4016
  dragImpulse(body?: Body | null): Vec3;
2867
4017
  /** Total impulse (buoyancy + drag). */
2868
4018
  totalImpulse(body?: Body | null, _freshOnly?: boolean): Vec3;
2869
4019
  }
2870
4020
 
2871
4021
  /**
2872
- * Return value flags for PreListener handlers.
4022
+ * Return value for {@link PreListener} handlers — controls whether the interaction
4023
+ * is resolved this step and in future steps.
2873
4024
  *
2874
- * - `ACCEPT` — accept the interaction
2875
- * - `IGNORE` — ignore the interaction
2876
- * - `ACCEPT_ONCE` — accept once, then revert
2877
- * - `IGNORE_ONCE` — ignore once, then revert
4025
+ * - `ACCEPT` — resolve the interaction (default if handler returns `null`)
4026
+ * - `IGNORE` — suppress the interaction permanently until the next `BEGIN`
4027
+ * - `ACCEPT_ONCE` — accept this step only, then revert to the previous flag
4028
+ * - `IGNORE_ONCE` — ignore this step only, then revert to the previous flag
4029
+ *
4030
+ * Use `IGNORE`/`ACCEPT` for stateful decisions (e.g., one-way platforms).
4031
+ * Use `*_ONCE` variants for single-step overrides.
2878
4032
  *
2879
4033
  * Converted from nape-compiled.js lines 2504–2591.
2880
4034
  */
2881
4035
  declare class PreFlag {
2882
4036
  static __name__: string[];
2883
4037
  constructor();
4038
+ /** Accept and resolve the interaction normally. */
2884
4039
  static get ACCEPT(): PreFlag;
4040
+ /** Suppress the interaction permanently until the next `BEGIN` event. */
2885
4041
  static get IGNORE(): PreFlag;
4042
+ /** Accept this step only; revert to the previous flag next step. */
2886
4043
  static get ACCEPT_ONCE(): PreFlag;
4044
+ /** Ignore this step only; revert to the previous flag next step. */
2887
4045
  static get IGNORE_ONCE(): PreFlag;
2888
4046
  toString(): string;
2889
4047
  }
2890
4048
 
2891
4049
  /**
2892
- * Represents an interaction arbiter between two shapes.
4050
+ * Represents an active interaction between two shapes.
4051
+ *
4052
+ * Arbiters are created and pooled internally by the engine — they cannot be
4053
+ * instantiated directly. Access them via:
4054
+ * - `space.arbiters` — all active arbiters in the simulation
4055
+ * - `body.arbiters` — arbiters involving a specific body
4056
+ * - `InteractionCallback.arbiters` — arbiters in an interaction callback
4057
+ * - `PreCallback.arbiter` — the arbiter in a pre-handler
2893
4058
  *
2894
- * Arbiters are pooled internally by the engine — they cannot be created directly.
2895
- * Access arbiters via `Space.arbiters`, `Body.arbiters`, or callback handlers.
4059
+ * Use {@link Arbiter.collisionArbiter} or {@link Arbiter.fluidArbiter} to cast
4060
+ * to a subtype for type-specific properties.
4061
+ *
4062
+ * **Warning:** do not hold references to `Arbiter` objects after the current
4063
+ * simulation step — they are pooled and may be reused.
2896
4064
  *
2897
4065
  * Fully modernized — uses extracted ZPP_Arbiter directly.
2898
4066
  */
@@ -2903,9 +4071,15 @@ declare class Arbiter {
2903
4071
  /** @internal Backward-compat: compiled code accesses `obj.zpp_inner`. */
2904
4072
  get _inner(): NapeInner;
2905
4073
  constructor();
2906
- /** Whether this arbiter is currently sleeping. */
4074
+ /**
4075
+ * Whether both interacting bodies are currently sleeping.
4076
+ * Throws if the arbiter is not active.
4077
+ */
2907
4078
  get isSleeping(): boolean;
2908
- /** The type of this arbiter (COLLISION, SENSOR, or FLUID). */
4079
+ /**
4080
+ * The interaction type of this arbiter.
4081
+ * @see {@link ArbiterType}
4082
+ */
2909
4083
  get type(): ArbiterType;
2910
4084
  /** Cast to CollisionArbiter if this is a collision, else null. */
2911
4085
  get collisionArbiter(): CollisionArbiter | null;
@@ -2928,8 +4102,15 @@ declare class Arbiter {
2928
4102
  /** Whether this is a sensor arbiter. */
2929
4103
  isSensorArbiter(): boolean;
2930
4104
  /**
2931
- * Total impulse of this arbiter. Base implementation returns Vec3(0,0,0).
2932
- * Overridden by CollisionArbiter and FluidArbiter.
4105
+ * Total impulse applied by this arbiter in the last step as `(fx, fy, torque)`.
4106
+ *
4107
+ * Pass a `body` to get the impulse applied specifically to that body.
4108
+ * Pass `freshOnly = true` to include only new contact points (not persistent ones).
4109
+ *
4110
+ * Overridden by {@link CollisionArbiter} and {@link FluidArbiter}.
4111
+ *
4112
+ * @param body - One of the two interacting bodies, or `null` for the combined impulse.
4113
+ * @param freshOnly - When `true`, only count fresh (new) contacts. Default `false`.
2933
4114
  */
2934
4115
  totalImpulse(body?: Body | null, _freshOnly?: boolean): Vec3;
2935
4116
  toString(): string;
@@ -3133,27 +4314,43 @@ declare class Contact {
3133
4314
  }
3134
4315
 
3135
4316
  /**
3136
- * Callback event types.
4317
+ * Enumeration of physics callback event types.
3137
4318
  *
3138
- * - `BEGIN` — interaction just started
3139
- * - `ONGOING` — interaction continues
3140
- * - `END` — interaction just ended
3141
- * - `WAKE` body/constraint woke up
3142
- * - `SLEEP` body/constraint went to sleep
3143
- * - `BREAK` constraint was broken
3144
- * - `PRE` pre-interaction callback
4319
+ * Use these singletons to specify which phase of an interaction a listener
4320
+ * should respond to:
4321
+ *
4322
+ * - `BEGIN` fired once when two interactors first make contact
4323
+ * - `ONGOING` fired every simulation step while the interaction persists
4324
+ * - `END` fired once when two interactors separate
4325
+ * - `WAKE` fired when a body or constraint wakes from sleep
4326
+ * - `SLEEP` — fired when a body or constraint falls asleep
4327
+ * - `BREAK` — fired when a constraint exceeds its `maxForce`/`maxError` and breaks
4328
+ * - `PRE` — fired before collision resolution; allows per-step accept/ignore decisions
4329
+ *
4330
+ * Valid events per listener type:
4331
+ * - {@link BodyListener}: `WAKE`, `SLEEP`
4332
+ * - {@link ConstraintListener}: `WAKE`, `SLEEP`, `BREAK`
4333
+ * - {@link InteractionListener}: `BEGIN`, `ONGOING`, `END`
4334
+ * - {@link PreListener}: always `PRE` (set internally)
3145
4335
  *
3146
4336
  * Converted from nape-compiled.js lines 516–657.
3147
4337
  */
3148
4338
  declare class CbEvent {
3149
4339
  static __name__: string[];
3150
4340
  constructor();
4341
+ /** Interaction-start event. Fired once when two interactors first make contact. */
3151
4342
  static get BEGIN(): CbEvent;
4343
+ /** Interaction-continue event. Fired every step while the interaction persists. */
3152
4344
  static get ONGOING(): CbEvent;
4345
+ /** Interaction-end event. Fired once when two interactors separate. */
3153
4346
  static get END(): CbEvent;
4347
+ /** Wake event. Fired when a body or constraint wakes from sleep. */
3154
4348
  static get WAKE(): CbEvent;
4349
+ /** Sleep event. Fired when a body or constraint falls asleep. */
3155
4350
  static get SLEEP(): CbEvent;
4351
+ /** Break event. Fired when a constraint exceeds its `maxForce` or `maxError` limit. */
3156
4352
  static get BREAK(): CbEvent;
4353
+ /** Pre-interaction event. Fired before collision resolution; handler can accept or ignore. */
3157
4354
  static get PRE(): CbEvent;
3158
4355
  toString(): string;
3159
4356
  }
@@ -3446,7 +4643,18 @@ declare class ZPP_CbType {
3446
4643
  }
3447
4644
 
3448
4645
  /**
3449
- * Composite callback option type — allows including and excluding CbTypes.
4646
+ * Composite callback option type — combines include and exclude {@link CbType} lists
4647
+ * to express complex listener filter conditions.
4648
+ *
4649
+ * An interaction satisfies an `OptionType` when the interactor has **at least one**
4650
+ * of the included types and **none** of the excluded types.
4651
+ *
4652
+ * @example
4653
+ * ```ts
4654
+ * // Listen only for bodies that are "enemy" but not "boss"
4655
+ * const filter = new OptionType(enemyType).excluding(bossType);
4656
+ * const listener = new BodyListener(CbEvent.WAKE, filter, (cb) => { ... });
4657
+ * ```
3450
4658
  *
3451
4659
  * Converted from nape-compiled.js lines 2647–2698.
3452
4660
  */
@@ -3454,18 +4662,55 @@ declare class OptionType {
3454
4662
  static __name__: string[];
3455
4663
  zpp_inner: ZPP_OptionType;
3456
4664
  get _inner(): NapeInner;
4665
+ /**
4666
+ * Creates an `OptionType` optionally seeded with initial include/exclude entries.
4667
+ *
4668
+ * @param includes - Initial type(s) to include.
4669
+ * @param excludes - Initial type(s) to exclude.
4670
+ */
3457
4671
  constructor(includes?: CbType | OptionType, excludes?: CbType | OptionType);
4672
+ /** Live list of `CbType`s that an interactor must have at least one of. */
3458
4673
  get includes(): object;
4674
+ /** Live list of `CbType`s that an interactor must have none of. */
3459
4675
  get excludes(): object;
4676
+ /**
4677
+ * Adds `includes` to the include list and returns `this` for chaining.
4678
+ *
4679
+ * @param includes - `CbType` or `OptionType` whose types should be added to includes.
4680
+ */
3460
4681
  including(includes: CbType | OptionType): this;
4682
+ /**
4683
+ * Adds `excludes` to the exclude list and returns `this` for chaining.
4684
+ *
4685
+ * @param excludes - `CbType` or `OptionType` whose types should be added to excludes.
4686
+ */
3461
4687
  excluding(excludes: CbType | OptionType): this;
3462
4688
  toString(): string;
3463
4689
  static _wrap(inner: any): OptionType;
3464
4690
  }
3465
4691
 
3466
4692
  /**
3467
- * Callback type — used to tag interactors so that listeners
3468
- * can filter which interactions they respond to.
4693
+ * Callback type tag — used to label bodies, shapes, and constraints so that
4694
+ * listeners can selectively respond to interactions involving specific objects.
4695
+ *
4696
+ * Objects can carry multiple `CbType`s (via their `cbTypes` list). Listeners
4697
+ * match against those types using {@link OptionType} include/exclude filters,
4698
+ * or using the built-in singletons (`ANY_BODY`, `ANY_SHAPE`, etc.).
4699
+ *
4700
+ * @example
4701
+ * ```ts
4702
+ * const playerType = new CbType();
4703
+ * body.cbTypes.add(playerType);
4704
+ *
4705
+ * const listener = new InteractionListener(
4706
+ * CbEvent.BEGIN,
4707
+ * InteractionType.COLLISION,
4708
+ * playerType,
4709
+ * null,
4710
+ * (cb) => { console.log('player hit something'); },
4711
+ * );
4712
+ * space.listeners.add(listener);
4713
+ * ```
3469
4714
  *
3470
4715
  * Converted from nape-compiled.js lines 689–770.
3471
4716
  */
@@ -3474,15 +4719,62 @@ declare class CbType {
3474
4719
  zpp_inner: ZPP_CbType;
3475
4720
  get _inner(): NapeInner;
3476
4721
  constructor();
4722
+ /**
4723
+ * Built-in type automatically assigned to every {@link Body}.
4724
+ * Use in listeners to respond to all bodies without a custom `CbType`.
4725
+ */
3477
4726
  static get ANY_BODY(): CbType;
4727
+ /**
4728
+ * Built-in type automatically assigned to every {@link Constraint}.
4729
+ *
4730
+ * **Note:** Constraints do NOT automatically carry `ANY_CONSTRAINT` in their
4731
+ * `cbTypes` list — you must add a custom CbType manually if you want to filter
4732
+ * constraint events.
4733
+ */
3478
4734
  static get ANY_CONSTRAINT(): CbType;
4735
+ /**
4736
+ * Built-in type automatically assigned to every {@link Shape}.
4737
+ * Use in listeners to respond to all shapes without a custom `CbType`.
4738
+ */
3479
4739
  static get ANY_SHAPE(): CbType;
4740
+ /**
4741
+ * Built-in type automatically assigned to every {@link Compound}.
4742
+ * Use in listeners to respond to all compounds without a custom `CbType`.
4743
+ */
3480
4744
  static get ANY_COMPOUND(): CbType;
4745
+ /** Unique numeric identifier for this `CbType` instance. */
3481
4746
  get id(): number;
4747
+ /**
4748
+ * Arbitrary user data attached to this `CbType`.
4749
+ *
4750
+ * Lazily initialized to `{}` on first access. Use to store application-level
4751
+ * metadata associated with the type.
4752
+ */
3482
4753
  get userData(): Record<string, unknown>;
4754
+ /**
4755
+ * Live list of all interactors (bodies/shapes/compounds) currently tagged
4756
+ * with this `CbType`. Read-only.
4757
+ */
3483
4758
  get interactors(): object;
4759
+ /**
4760
+ * Live list of all constraints currently tagged with this `CbType`. Read-only.
4761
+ */
3484
4762
  get constraints(): object;
4763
+ /**
4764
+ * Creates a new {@link OptionType} that includes this type and also `includes`.
4765
+ *
4766
+ * Shorthand for `new OptionType(this).including(includes)`.
4767
+ *
4768
+ * @param includes - Additional `CbType` or `OptionType` to require.
4769
+ */
3485
4770
  including(includes: CbType | OptionType): OptionType;
4771
+ /**
4772
+ * Creates a new {@link OptionType} that includes this type but excludes `excludes`.
4773
+ *
4774
+ * Shorthand for `new OptionType(this).excluding(excludes)`.
4775
+ *
4776
+ * @param excludes - `CbType` or `OptionType` to reject.
4777
+ */
3486
4778
  excluding(excludes: CbType | OptionType): OptionType;
3487
4779
  toString(): string;
3488
4780
  static _wrap(inner: any): CbType;
@@ -3517,27 +4809,68 @@ declare class ListenerType {
3517
4809
  * Fully modernized from nape-compiled.js lines 231–433.
3518
4810
  */
3519
4811
 
4812
+ /**
4813
+ * Base class for all physics event listeners.
4814
+ *
4815
+ * Cannot be instantiated directly — use one of the concrete subclasses:
4816
+ * {@link BodyListener}, {@link ConstraintListener}, {@link InteractionListener},
4817
+ * or {@link PreListener}.
4818
+ *
4819
+ * Provides common properties (`type`, `event`, `precedence`, `space`) shared
4820
+ * by all listener types.
4821
+ *
4822
+ * Fully modernized from nape-compiled.js lines 231–433.
4823
+ */
3520
4824
  declare class Listener {
3521
4825
  static __name__: string[];
3522
4826
  zpp_inner: ZPP_Listener;
3523
4827
  get _inner(): this;
3524
4828
  constructor();
3525
4829
  static _wrap(inner: ZPP_Listener | Listener | null | undefined): Listener;
4830
+ /** The type of this listener (BODY, CONSTRAINT, INTERACTION, or PRE). */
3526
4831
  get type(): ListenerType;
4832
+ /**
4833
+ * The event this listener responds to.
4834
+ *
4835
+ * Valid values depend on the concrete listener type — see {@link CbEvent}.
4836
+ * Changing this while the listener is assigned to a space re-registers it.
4837
+ */
3527
4838
  get event(): CbEvent;
3528
4839
  set event(event: CbEvent);
4840
+ /**
4841
+ * Execution priority of this listener relative to other listeners for the
4842
+ * same event. Higher values execute first.
4843
+ *
4844
+ * @defaultValue `0`
4845
+ */
3529
4846
  get precedence(): number;
3530
4847
  set precedence(precedence: number);
4848
+ /**
4849
+ * The space this listener is currently registered in, or `null` if not registered.
4850
+ *
4851
+ * Assign to register/unregister the listener in a space:
4852
+ * ```ts
4853
+ * listener.space = mySpace; // register
4854
+ * listener.space = null; // unregister
4855
+ * ```
4856
+ */
3531
4857
  get space(): Space | null;
3532
4858
  set space(space: Space | null);
3533
4859
  toString(): string;
3534
4860
  }
3535
4861
 
3536
4862
  /**
3537
- * Base class for all physics engine callbacks.
4863
+ * Base class for all physics engine callback objects.
3538
4864
  *
3539
- * Cannot be instantiated directly — instances are created internally by the engine
3540
- * and passed to listener handlers.
4865
+ * Callback instances are created internally by the engine and passed to listener
4866
+ * handler functions. They must not be stored beyond the scope of the handler —
4867
+ * they are pooled and reused after the handler returns.
4868
+ *
4869
+ * Concrete subclasses:
4870
+ * - {@link BodyCallback} — passed to {@link BodyListener} handlers
4871
+ * - {@link ConstraintCallback} — passed to {@link ConstraintListener} handlers
4872
+ * - {@link InteractionCallback} — passed to {@link InteractionListener} handlers
4873
+ * - {@link PreCallback} — passed to {@link PreListener} handlers
3541
4874
  *
3542
4875
  * Converted from nape-compiled.js lines 212–238.
3543
4876
  */
@@ -3545,20 +4878,24 @@ declare class Callback {
3545
4878
  static __name__: string[];
3546
4879
  zpp_inner: ZPP_Callback | null;
3547
4880
  constructor();
4881
+ /** The event type that caused this callback to fire (e.g., `CbEvent.BEGIN`). */
3548
4882
  get event(): CbEvent;
4883
+ /** The listener that this callback was fired from. */
3549
4884
  get listener(): Listener;
3550
4885
  toString(): string;
3551
4886
  }
3552
4887
 
3553
4888
  /**
3554
- * Callback for body events (WAKE/SLEEP).
4889
+ * Callback object passed to {@link BodyListener} handlers.
3555
4890
  *
3556
- * Cannot be instantiated directly instances are created internally by the engine.
4891
+ * Provides the body that triggered the event. Do not store this object beyond
4892
+ * the handler scope — it is pooled and reused.
3557
4893
  *
3558
4894
  * Converted from nape-compiled.js lines 239–261.
3559
4895
  */
3560
4896
  declare class BodyCallback extends Callback {
3561
4897
  static __name__: string[];
4898
+ /** The body that woke or fell asleep. */
3562
4899
  get body(): Body;
3563
4900
  toString(): string;
3564
4901
  }
@@ -3569,27 +4906,67 @@ declare class BodyCallback extends Callback {
3569
4906
  * Fully modernized from nape-compiled.js lines 434–515.
3570
4907
  */
3571
4908
 
4909
+ /**
4910
+ * Listener for body lifecycle events.
4911
+ *
4912
+ * Fires when a body matching the `options` filter wakes or sleeps.
4913
+ *
4914
+ * Valid events: {@link CbEvent.WAKE}, {@link CbEvent.SLEEP}.
4915
+ *
4916
+ * @example
4917
+ * ```ts
4918
+ * const listener = new BodyListener(
4919
+ * CbEvent.WAKE,
4920
+ * CbType.ANY_BODY,
4921
+ * (cb) => { console.log(cb.body, 'woke up'); },
4922
+ * );
4923
+ * space.listeners.add(listener);
4924
+ * ```
4925
+ *
4926
+ * Fully modernized from nape-compiled.js lines 434–515.
4927
+ */
3572
4928
  declare class BodyListener extends Listener {
3573
4929
  static __name__: string[];
3574
4930
  zpp_inner_zn: ZPP_BodyListener;
4931
+ /**
4932
+ * @param event - Must be `CbEvent.WAKE` or `CbEvent.SLEEP`.
4933
+ * @param options - `CbType` or `OptionType` filter, or `null` to match all bodies.
4934
+ * @param handler - Called with a {@link BodyCallback} each time the event fires.
4935
+ * @param precedence - Execution order relative to other listeners (higher = first). Default `0`.
4936
+ */
3575
4937
  constructor(event: CbEvent, options: OptionType | CbType | null, handler: (cb: BodyCallback) => void, precedence?: number);
4938
+ /**
4939
+ * The filter used to match bodies. Returns an {@link OptionType} representing
4940
+ * the current include/exclude configuration.
4941
+ */
3576
4942
  get options(): OptionType;
3577
4943
  set options(options: OptionType | CbType);
4944
+ /** The callback function invoked when the event fires. Cannot be set to null. */
3578
4945
  get handler(): (cb: BodyCallback) => void;
3579
4946
  set handler(handler: (cb: BodyCallback) => void);
3580
4947
  }
3581
4948
 
3582
4949
  /**
3583
- * Callback for interaction events (BEGIN/END/ONGOING).
4950
+ * Callback object passed to {@link InteractionListener} handlers.
3584
4951
  *
3585
- * Cannot be instantiated directly instances are created internally by the engine.
4952
+ * Provides both interactors and the list of active arbiters between them.
4953
+ * Do not store this object beyond the handler scope — it is pooled and reused.
3586
4954
  *
3587
4955
  * Converted from nape-compiled.js lines 1398–1445.
3588
4956
  */
3589
4957
  declare class InteractionCallback extends Callback {
3590
4958
  static __name__: string[];
4959
+ /** The first interactor involved in the interaction. */
3591
4960
  get int1(): Interactor;
4961
+ /** The second interactor involved in the interaction. */
3592
4962
  get int2(): Interactor;
4963
+ /**
4964
+ * The list of arbiters currently active between `int1` and `int2`.
4965
+ *
4966
+ * For `ONGOING` callbacks, arbiters are valid for the entire step.
4967
+ * For `BEGIN`/`END` callbacks, the list reflects the state at the moment
4968
+ * the event fired.
4969
+ */
3593
4970
  get arbiters(): object;
3594
4971
  toString(): string;
3595
4972
  }
@@ -3600,31 +4977,75 @@ declare class InteractionCallback extends Callback {
3600
4977
  * Fully modernized from nape-compiled.js lines 659–1091.
3601
4978
  */
3602
4979
 
4980
+ /**
4981
+ * Listener for interaction events between two interactors.
4982
+ *
4983
+ * Fires when two objects matching `options1` and `options2` start, continue, or
4984
+ * stop interacting with each other according to `interactionType`.
4985
+ *
4986
+ * Valid events: {@link CbEvent.BEGIN}, {@link CbEvent.ONGOING}, {@link CbEvent.END}.
4987
+ *
4988
+ * - `BEGIN` fires once when the interaction starts.
4989
+ * - `ONGOING` fires every simulation step while the interaction persists.
4990
+ * - `END` fires once when the interaction ends.
4991
+ *
4992
+ * @example
4993
+ * ```ts
4994
+ * const listener = new InteractionListener(
4995
+ * CbEvent.BEGIN,
4996
+ * InteractionType.COLLISION,
4997
+ * playerType,
4998
+ * groundType,
4999
+ * (cb) => { console.log('player landed'); },
5000
+ * );
5001
+ * space.listeners.add(listener);
5002
+ * ```
5003
+ *
5004
+ * Fully modernized from nape-compiled.js lines 659–1091.
5005
+ */
3603
5006
  declare class InteractionListener extends Listener {
3604
5007
  static __name__: string[];
3605
5008
  zpp_inner_zn: ZPP_InteractionListener;
5009
+ /**
5010
+ * @param event - Must be `CbEvent.BEGIN`, `CbEvent.ONGOING`, or `CbEvent.END`.
5011
+ * @param interactionType - The kind of interaction to listen for (COLLISION, SENSOR, FLUID, or ANY).
5012
+ * @param options1 - Filter for the first interactor, or `null` to match any.
5013
+ * @param options2 - Filter for the second interactor, or `null` to match any.
5014
+ * @param handler - Called with an {@link InteractionCallback} each time the event fires.
5015
+ * @param precedence - Execution order relative to other listeners (higher = first). Default `0`.
5016
+ */
3606
5017
  constructor(event: CbEvent, interactionType: InteractionType, options1: OptionType | CbType | null, options2: OptionType | CbType | null, handler: (cb: InteractionCallback) => void, precedence?: number);
5018
+ /** Filter for the first interactor. Order between `options1`/`options2` does not matter. */
3607
5019
  get options1(): OptionType;
3608
5020
  set options1(options1: OptionType | CbType);
5021
+ /** Filter for the second interactor. Order between `options1`/`options2` does not matter. */
3609
5022
  get options2(): OptionType;
3610
5023
  set options2(options2: OptionType | CbType);
5024
+ /** The callback function invoked when the event fires. Cannot be set to null. */
3611
5025
  get handler(): (cb: InteractionCallback) => void;
3612
5026
  set handler(handler: (cb: InteractionCallback) => void);
5027
+ /** The type of interaction this listener responds to (COLLISION, SENSOR, FLUID, or ANY). */
3613
5028
  get interactionType(): InteractionType | null;
3614
5029
  set interactionType(interactionType: InteractionType | null);
5030
+ /**
5031
+ * When `true`, `ONGOING` callbacks are also fired while both interactors are sleeping.
5032
+ * Default is `false` (callbacks are suppressed when both are asleep).
5033
+ */
3615
5034
  get allowSleepingCallbacks(): boolean;
3616
5035
  set allowSleepingCallbacks(value: boolean);
3617
5036
  }
3618
5037
 
3619
5038
  /**
3620
- * Callback for constraint events (WAKE/SLEEP/BREAK).
5039
+ * Callback object passed to {@link ConstraintListener} handlers.
3621
5040
  *
3622
- * Cannot be instantiated directly instances are created internally by the engine.
5041
+ * Provides the constraint that triggered the event. Do not store this object
5042
+ * beyond the handler scope — it is pooled and reused.
3623
5043
  *
3624
5044
  * Converted from nape-compiled.js lines 1262–1292.
3625
5045
  */
3626
5046
  declare class ConstraintCallback extends Callback {
3627
5047
  static __name__: string[];
5048
+ /** The constraint that woke, fell asleep, or broke. */
3628
5049
  get constraint(): Constraint;
3629
5050
  toString(): string;
3630
5051
  }
@@ -3635,28 +5056,72 @@ declare class ConstraintCallback extends Callback {
3635
5056
  * Fully modernized from nape-compiled.js lines 546–649.
3636
5057
  */
3637
5058
 
5059
+ /**
5060
+ * Listener for constraint lifecycle events.
5061
+ *
5062
+ * Fires when a constraint matching the `options` filter wakes, sleeps, or breaks.
5063
+ *
5064
+ * Valid events: {@link CbEvent.WAKE}, {@link CbEvent.SLEEP}, {@link CbEvent.BREAK}.
5065
+ *
5066
+ * A `BREAK` event fires when the constraint exceeds its `maxForce` or `maxError` limit.
5067
+ * If `removeOnBreak` is `true` on the constraint it is also removed from the space.
5068
+ *
5069
+ * @example
5070
+ * ```ts
5071
+ * const listener = new ConstraintListener(
5072
+ * CbEvent.BREAK,
5073
+ * myConstraintType,
5074
+ * (cb) => { console.log(cb.constraint, 'broke!'); },
5075
+ * );
5076
+ * space.listeners.add(listener);
5077
+ * ```
5078
+ *
5079
+ * Fully modernized from nape-compiled.js lines 546–649.
5080
+ */
3638
5081
  declare class ConstraintListener extends Listener {
3639
5082
  static __name__: string[];
3640
5083
  zpp_inner_zn: ZPP_ConstraintListener;
5084
+ /**
5085
+ * @param event - Must be `CbEvent.WAKE`, `CbEvent.SLEEP`, or `CbEvent.BREAK`.
5086
+ * @param options - `CbType` or `OptionType` filter, or `null` to match all constraints.
5087
+ * @param handler - Called with a {@link ConstraintCallback} each time the event fires.
5088
+ * @param precedence - Execution order relative to other listeners (higher = first). Default `0`.
5089
+ */
3641
5090
  constructor(event: CbEvent, options: OptionType | CbType | null, handler: (cb: ConstraintCallback) => void, precedence?: number);
5091
+ /**
5092
+ * The filter used to match constraints. Returns an {@link OptionType} representing
5093
+ * the current include/exclude configuration.
5094
+ */
3642
5095
  get options(): OptionType;
3643
5096
  set options(options: OptionType | CbType);
5097
+ /** The callback function invoked when the event fires. Cannot be set to null. */
3644
5098
  get handler(): (cb: ConstraintCallback) => void;
3645
5099
  set handler(handler: (cb: ConstraintCallback) => void);
3646
5100
  }
3647
5101
 
3648
5102
  /**
3649
- * Callback for pre-interaction events.
5103
+ * Callback object passed to {@link PreListener} handlers.
5104
+ *
5105
+ * Provides both interactors, the arbiter, and a `swapped` flag indicating
5106
+ * whether the pair order was swapped relative to the listener's `options1`/`options2`.
3650
5107
  *
3651
- * Cannot be instantiated directly instances are created internally by the engine.
5108
+ * The handler should return a {@link PreFlag} to control the interaction.
5109
+ * Do not store this object beyond the handler scope — it is pooled and reused.
3652
5110
  *
3653
5111
  * Converted from nape-compiled.js lines 2590–2634.
3654
5112
  */
3655
5113
  declare class PreCallback extends Callback {
3656
5114
  static __name__: string[];
5115
+ /** The arbiter representing the potential interaction. Use to inspect collision normal, etc. */
3657
5116
  get arbiter(): Arbiter;
5117
+ /** The first interactor in the pair (matches `options1` unless `swapped` is `true`). */
3658
5118
  get int1(): Interactor;
5119
+ /** The second interactor in the pair (matches `options2` unless `swapped` is `true`). */
3659
5120
  get int2(): Interactor;
5121
+ /**
5122
+ * `true` when the pair order is swapped relative to the listener's `options1`/`options2`.
5123
+ * Check this if you need to know which interactor matched which filter.
5124
+ */
3660
5125
  get swapped(): boolean;
3661
5126
  toString(): string;
3662
5127
  }
@@ -3669,18 +5134,74 @@ declare class PreCallback extends Callback {
3669
5134
  * Fully modernized from nape-compiled.js lines 1142–1338.
3670
5135
  */
3671
5136
 
5137
+ /**
5138
+ * Pre-interaction listener — called before collision resolution each step.
5139
+ *
5140
+ * The handler receives a {@link PreCallback} and returns a {@link PreFlag} that
5141
+ * determines whether and how the interaction should be processed:
5142
+ * - `PreFlag.ACCEPT` — resolve the interaction normally (default).
5143
+ * - `PreFlag.IGNORE` — suppress the interaction permanently (until next `BEGIN`).
5144
+ * - `PreFlag.ACCEPT_ONCE` — accept this step, then revert to default.
5145
+ * - `PreFlag.IGNORE_ONCE` — ignore this step only.
5146
+ *
5147
+ * Returning `null` is equivalent to `ACCEPT`.
5148
+ *
5149
+ * The event is always {@link CbEvent.PRE} and cannot be changed.
5150
+ *
5151
+ * **Pure mode**: when `pure` is `true` the engine caches the handler result and
5152
+ * does not re-invoke it until the result is reset. This is an optimisation — only
5153
+ * use `pure` when the handler will always return the same flag for a given pair.
5154
+ *
5155
+ * @example
5156
+ * ```ts
5157
+ * const preListener = new PreListener(
5158
+ * InteractionType.COLLISION,
5159
+ * playerType,
5160
+ * onewayPlatformType,
5161
+ * (cb) => cb.arbiter.collisionArbiter!.normal.y > 0
5162
+ * ? PreFlag.ACCEPT
5163
+ * : PreFlag.IGNORE,
5164
+ * );
5165
+ * space.listeners.add(preListener);
5166
+ * ```
5167
+ *
5168
+ * Fully modernized from nape-compiled.js lines 1142–1338.
5169
+ */
3672
5170
  declare class PreListener extends Listener {
3673
5171
  static __name__: string[];
3674
5172
  zpp_inner_zn: ZPP_InteractionListener;
5173
+ /**
5174
+ * @param interactionType - The kind of interaction to intercept (COLLISION, SENSOR, FLUID, or ANY).
5175
+ * @param options1 - Filter for the first interactor, or `null` to match any.
5176
+ * @param options2 - Filter for the second interactor, or `null` to match any.
5177
+ * @param handler - Called each step; return a {@link PreFlag} to control the interaction.
5178
+ * @param precedence - Execution order relative to other listeners (higher = first). Default `0`.
5179
+ * @param pure - Enable caching of the handler result. Default `false`.
5180
+ */
3675
5181
  constructor(interactionType: InteractionType, options1: OptionType | CbType | null, options2: OptionType | CbType | null, handler: (cb: PreCallback) => PreFlag | null, precedence?: number, pure?: boolean);
5182
+ /** Filter for the first interactor. Order does not matter. */
3676
5183
  get options1(): OptionType;
3677
5184
  set options1(options1: OptionType | CbType);
5185
+ /** Filter for the second interactor. Order does not matter. */
3678
5186
  get options2(): OptionType;
3679
5187
  set options2(options2: OptionType | CbType);
5188
+ /**
5189
+ * The handler called before each collision resolution step.
5190
+ * Return a {@link PreFlag} to accept/ignore the interaction, or `null` to accept.
5191
+ */
3680
5192
  get handler(): (cb: PreCallback) => PreFlag | null;
3681
5193
  set handler(handler: (cb: PreCallback) => PreFlag | null);
5194
+ /**
5195
+ * When `true`, the engine caches the handler return value and does not
5196
+ * re-invoke the handler until the cached result is invalidated.
5197
+ *
5198
+ * Only use `pure` mode when the handler always returns the same flag for a
5199
+ * given pair of interactors. Setting `pure` to `false` immediately invalidates
5200
+ * any cached result.
5201
+ */
3682
5202
  get pure(): boolean;
3683
5203
  set pure(pure: boolean);
5204
+ /** The type of interaction this pre-listener intercepts (COLLISION, SENSOR, FLUID, or ANY). */
3684
5205
  get interactionType(): InteractionType | null;
3685
5206
  set interactionType(interactionType: InteractionType | null);
3686
5207
  }
@@ -3747,25 +5268,53 @@ declare class ZPP_PivotJoint extends ZPP_Constraint {
3747
5268
  }
3748
5269
 
3749
5270
  /**
3750
- * A pivot (pin) joint that constrains two bodies to share an anchor point.
5271
+ * A pivot (pin) joint that constrains two anchor points one on each body — to
5272
+ * remain coincident in world space.
5273
+ *
5274
+ * This is the most common joint type and is used to simulate hinges, pins, and
5275
+ * revolute connections between bodies.
5276
+ *
5277
+ * The constraint eliminates 2 translational degrees of freedom but leaves
5278
+ * rotation free.
5279
+ *
5280
+ * @example
5281
+ * ```ts
5282
+ * // Pin body2 to body1's local origin
5283
+ * const joint = new PivotJoint(
5284
+ * body1, body2,
5285
+ * Vec2.weak(0, 0), // anchor on body1 (local)
5286
+ * Vec2.weak(0, 0), // anchor on body2 (local)
5287
+ * );
5288
+ * joint.space = space;
5289
+ * ```
3751
5290
  *
3752
5291
  * Fully modernized — uses ZPP_PivotJoint directly (extracted to TypeScript).
3753
5292
  */
3754
5293
  declare class PivotJoint extends Constraint {
3755
5294
  zpp_inner: ZPP_PivotJoint;
5295
+ /**
5296
+ * @param body1 - First body, or `null` for a static world anchor.
5297
+ * @param body2 - Second body, or `null` for a static world anchor.
5298
+ * @param anchor1 - Anchor point in `body1`'s local space (disposed if weak).
5299
+ * @param anchor2 - Anchor point in `body2`'s local space (disposed if weak).
5300
+ */
3756
5301
  constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2);
3757
5302
  /** @internal */
3758
5303
  static _wrap(inner: any): PivotJoint;
5304
+ /** First body. `null` treats the anchor as a static world point. */
3759
5305
  get body1(): Body;
3760
5306
  set body1(value: Body | null);
3761
5307
  /** @internal */
3762
5308
  private _setBody1;
5309
+ /** Second body. `null` treats the anchor as a static world point. */
3763
5310
  get body2(): Body;
3764
5311
  set body2(value: Body | null);
3765
5312
  /** @internal */
3766
5313
  private _setBody2;
5314
+ /** Anchor point on `body1` in local coordinates. */
3767
5315
  get anchor1(): Vec2;
3768
5316
  set anchor1(value: Vec2);
5317
+ /** Anchor point on `body2` in local coordinates. */
3769
5318
  get anchor2(): Vec2;
3770
5319
  set anchor2(value: Vec2);
3771
5320
  impulse(): MatMN;
@@ -3851,31 +5400,70 @@ declare class ZPP_DistanceJoint extends ZPP_Constraint {
3851
5400
  }
3852
5401
 
3853
5402
  /**
3854
- * Constrains the distance between two anchor points on two bodies.
5403
+ * Constrains the distance between two anchor points (one on each body) within a range.
5404
+ *
5405
+ * Enforces: `jointMin ≤ distance(anchor1, anchor2) ≤ jointMax`
5406
+ *
5407
+ * When `jointMin === jointMax` the distance is fixed (like a rigid rod).
5408
+ * When `jointMin < jointMax` the joint acts as a slack rope / elastic band.
5409
+ *
5410
+ * Anchors are specified in each body's local coordinate space.
5411
+ *
5412
+ * @example
5413
+ * ```ts
5414
+ * // Attach two bodies with a fixed-length rod
5415
+ * const joint = new DistanceJoint(
5416
+ * body1, body2,
5417
+ * Vec2.weak(0, 0), // anchor on body1 (local)
5418
+ * Vec2.weak(0, 0), // anchor on body2 (local)
5419
+ * 50, 50, // fixed distance
5420
+ * );
5421
+ * joint.space = space;
5422
+ * ```
3855
5423
  *
3856
5424
  * Fully modernized — uses ZPP_DistanceJoint directly (extracted to TypeScript).
3857
5425
  */
3858
5426
  declare class DistanceJoint extends Constraint {
3859
5427
  zpp_inner: ZPP_DistanceJoint;
5428
+ /**
5429
+ * @param body1 - First body, or `null` for a static world anchor.
5430
+ * @param body2 - Second body, or `null` for a static world anchor.
5431
+ * @param anchor1 - Anchor point in `body1`'s local space (disposed if weak).
5432
+ * @param anchor2 - Anchor point in `body2`'s local space (disposed if weak).
5433
+ * @param jointMin - Minimum allowed distance (must be `>= 0`).
5434
+ * @param jointMax - Maximum allowed distance (must be `>= jointMin`).
5435
+ */
3860
5436
  constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, jointMin: number, jointMax: number);
3861
5437
  /** @internal */
3862
5438
  static _wrap(inner: any): DistanceJoint;
5439
+ /** First body. `null` treats the anchor as a static world point. */
3863
5440
  get body1(): Body;
3864
5441
  set body1(value: Body | null);
3865
5442
  /** @internal */
3866
5443
  private _setBody1;
5444
+ /** Second body. `null` treats the anchor as a static world point. */
3867
5445
  get body2(): Body;
3868
5446
  set body2(value: Body | null);
3869
5447
  /** @internal */
3870
5448
  private _setBody2;
5449
+ /** Anchor point on `body1` in local coordinates. Modifying this wakes the constraint. */
3871
5450
  get anchor1(): Vec2;
3872
5451
  set anchor1(value: Vec2);
5452
+ /** Anchor point on `body2` in local coordinates. Modifying this wakes the constraint. */
3873
5453
  get anchor2(): Vec2;
3874
5454
  set anchor2(value: Vec2);
5455
+ /** Minimum allowed distance between anchors (pixels, must be `>= 0`). */
3875
5456
  get jointMin(): number;
3876
5457
  set jointMin(value: number);
5458
+ /** Maximum allowed distance between anchors (pixels, must be `>= jointMin`). */
3877
5459
  get jointMax(): number;
3878
5460
  set jointMax(value: number);
5461
+ /**
5462
+ * Returns `true` when the current distance is within `[jointMin, jointMax]`
5463
+ * and no corrective impulse was applied last step.
5464
+ *
5465
+ * @throws if either body is `null`.
5466
+ */
3879
5467
  isSlack(): boolean;
3880
5468
  impulse(): MatMN;
3881
5469
  bodyImpulse(body: Body): Vec3;
@@ -3940,29 +5528,69 @@ declare class ZPP_AngleJoint extends ZPP_Constraint {
3940
5528
  }
3941
5529
 
3942
5530
  /**
3943
- * Constrains the relative angle between two bodies.
5531
+ * Constrains the relative angle between two bodies within a range.
5532
+ *
5533
+ * The constraint enforces:
5534
+ * `jointMin ≤ body2.rotation - ratio * body1.rotation ≤ jointMax`
5535
+ *
5536
+ * When `jointMin === jointMax` the relative angle is fixed exactly.
5537
+ * When `jointMin < jointMax` the joint acts as a rotational limit.
5538
+ *
5539
+ * @example
5540
+ * ```ts
5541
+ * // Limit the angle between two bodies to ±45 degrees
5542
+ * const joint = new AngleJoint(
5543
+ * body1, body2,
5544
+ * -Math.PI / 4, // jointMin
5545
+ * Math.PI / 4, // jointMax
5546
+ * );
5547
+ * joint.space = space;
5548
+ * ```
3944
5549
  *
3945
5550
  * Fully modernized — uses ZPP_AngleJoint directly (extracted to TypeScript).
3946
5551
  */
3947
5552
  declare class AngleJoint extends Constraint {
3948
5553
  zpp_inner: ZPP_AngleJoint;
5554
+ /**
5555
+ * @param body1 - First body, or `null` for a static anchor.
5556
+ * @param body2 - Second body, or `null` for a static anchor.
5557
+ * @param jointMin - Minimum allowed relative angle (radians).
5558
+ * @param jointMax - Maximum allowed relative angle (radians).
5559
+ * @param ratio - Gear ratio applied to `body1`'s rotation. Default `1.0`.
5560
+ */
3949
5561
  constructor(body1: Body | null, body2: Body | null, jointMin: number, jointMax: number, ratio?: number);
3950
5562
  /** @internal */
3951
5563
  static _wrap(inner: any): AngleJoint;
5564
+ /** First body in the constraint. Setting `null` treats it as a static world-anchored reference. */
3952
5565
  get body1(): Body;
3953
5566
  set body1(value: Body | null);
3954
5567
  /** @internal */
3955
5568
  private _setBody1;
5569
+ /** Second body in the constraint. Setting `null` treats it as a static world-anchored reference. */
3956
5570
  get body2(): Body;
3957
5571
  set body2(value: Body | null);
3958
5572
  /** @internal */
3959
5573
  private _setBody2;
5574
+ /** Minimum allowed relative angle in radians (`jointMin ≤ jointMax`). */
3960
5575
  get jointMin(): number;
3961
5576
  set jointMin(value: number);
5577
+ /** Maximum allowed relative angle in radians (`jointMin ≤ jointMax`). */
3962
5578
  get jointMax(): number;
3963
5579
  set jointMax(value: number);
5580
+ /**
5581
+ * Gear ratio applied to `body1`'s rotation.
5582
+ *
5583
+ * The constraint enforces `jointMin ≤ body2.rotation - ratio * body1.rotation ≤ jointMax`.
5584
+ * @defaultValue `1.0`
5585
+ */
3964
5586
  get ratio(): number;
3965
5587
  set ratio(value: number);
5588
+ /**
5589
+ * Returns `true` when the current relative angle is within `[jointMin, jointMax]`
5590
+ * and no corrective impulse was applied last step.
5591
+ *
5592
+ * @throws if either body is `null`.
5593
+ */
3966
5594
  isSlack(): boolean;
3967
5595
  impulse(): MatMN;
3968
5596
  bodyImpulse(body: Body): Vec3;
@@ -4040,28 +5668,59 @@ declare class ZPP_WeldJoint extends ZPP_Constraint {
4040
5668
  }
4041
5669
 
4042
5670
  /**
4043
- * Weld joint — constrains two bodies to maintain a fixed relative
4044
- * position and angle (like gluing them together).
5671
+ * Weld joint — constrains two bodies to maintain a fixed relative position and
5672
+ * relative angle, effectively gluing them together while still treating them as
5673
+ * separate physics objects.
5674
+ *
5675
+ * The `phase` parameter sets the desired relative angle offset in radians.
5676
+ * When `phase = 0` both bodies maintain the angle difference they had at the
5677
+ * time the joint was created.
5678
+ *
5679
+ * @example
5680
+ * ```ts
5681
+ * const joint = new WeldJoint(
5682
+ * body1, body2,
5683
+ * Vec2.weak(10, 0), // attach point on body1
5684
+ * Vec2.weak(-10, 0), // attach point on body2
5685
+ * );
5686
+ * joint.space = space;
5687
+ * ```
4045
5688
  *
4046
5689
  * Fully modernized — uses ZPP_WeldJoint directly (extracted to TypeScript).
4047
5690
  */
4048
5691
  declare class WeldJoint extends Constraint {
4049
5692
  zpp_inner: ZPP_WeldJoint;
5693
+ /**
5694
+ * @param body1 - First body, or `null` for a static world anchor.
5695
+ * @param body2 - Second body, or `null` for a static world anchor.
5696
+ * @param anchor1 - Anchor point in `body1`'s local space (disposed if weak).
5697
+ * @param anchor2 - Anchor point in `body2`'s local space (disposed if weak).
5698
+ * @param phase - Target relative angle offset in radians. Default `0.0`.
5699
+ */
4050
5700
  constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, phase?: number);
4051
5701
  /** @internal */
4052
5702
  static _wrap(inner: any): WeldJoint;
5703
+ /** First body. `null` treats the anchor as a static world point. */
4053
5704
  get body1(): Body;
4054
5705
  set body1(value: Body | null);
4055
5706
  /** @internal */
4056
5707
  private _setBody1;
5708
+ /** Second body. `null` treats the anchor as a static world point. */
4057
5709
  get body2(): Body;
4058
5710
  set body2(value: Body | null);
4059
5711
  /** @internal */
4060
5712
  private _setBody2;
5713
+ /** Anchor point on `body1` in local coordinates. */
4061
5714
  get anchor1(): Vec2;
4062
5715
  set anchor1(value: Vec2);
5716
+ /** Anchor point on `body2` in local coordinates. */
4063
5717
  get anchor2(): Vec2;
4064
5718
  set anchor2(value: Vec2);
5719
+ /**
5720
+ * Target relative angle offset in radians.
5721
+ * `0` means both bodies maintain their original angle difference.
5722
+ * @defaultValue `0.0`
5723
+ */
4065
5724
  get phase(): number;
4066
5725
  set phase(value: number);
4067
5726
  impulse(): MatMN;
@@ -4111,25 +5770,60 @@ declare class ZPP_MotorJoint extends ZPP_Constraint {
4111
5770
  }
4112
5771
 
4113
5772
  /**
4114
- * Motor joint — applies angular velocity to rotate bodies relative to each other.
5773
+ * Motor joint — drives the relative angular velocity between two bodies toward
5774
+ * a target `rate`, subject to `maxForce`.
5775
+ *
5776
+ * The motor enforces: `body2.angularVel - ratio * body1.angularVel → rate`
5777
+ *
5778
+ * This is a velocity-level constraint (not positional), so it does not enforce
5779
+ * a particular relative angle — it continuously applies torque to reach `rate`.
5780
+ * Use an {@link AngleJoint} in addition if you also need an angle limit.
5781
+ *
5782
+ * @example
5783
+ * ```ts
5784
+ * // Spin body2 at 2 rad/s relative to body1, limited to 500 N force
5785
+ * const motor = new MotorJoint(body1, body2, 2.0);
5786
+ * motor.maxForce = 500;
5787
+ * motor.space = space;
5788
+ * ```
4115
5789
  *
4116
5790
  * Fully modernized — uses ZPP_MotorJoint directly (extracted to TypeScript).
4117
5791
  */
4118
5792
  declare class MotorJoint extends Constraint {
4119
5793
  zpp_inner: ZPP_MotorJoint;
5794
+ /**
5795
+ * @param body1 - First body, or `null` for a static world reference.
5796
+ * @param body2 - Second body, or `null` for a static world reference.
5797
+ * @param rate - Target relative angular velocity (rad/s). Default `0.0`.
5798
+ * @param ratio - Gear ratio applied to `body1`'s angular velocity. Default `1.0`.
5799
+ */
4120
5800
  constructor(body1: Body | null, body2: Body | null, rate?: number, ratio?: number);
4121
5801
  /** @internal */
4122
5802
  static _wrap(inner: any): MotorJoint;
5803
+ /** First body (its angular velocity is scaled by `ratio`). */
4123
5804
  get body1(): Body;
4124
5805
  set body1(value: Body | null);
4125
5806
  /** @internal */
4126
5807
  private _setBody1;
5808
+ /** Second body (driven toward the target angular velocity). */
4127
5809
  get body2(): Body;
4128
5810
  set body2(value: Body | null);
4129
5811
  /** @internal */
4130
5812
  private _setBody2;
5813
+ /**
5814
+ * Target relative angular velocity in rad/s.
5815
+ *
5816
+ * Positive values rotate `body2` counter-clockwise relative to `body1`.
5817
+ * @defaultValue `0.0`
5818
+ */
4131
5819
  get rate(): number;
4132
5820
  set rate(value: number);
5821
+ /**
5822
+ * Gear ratio applied to `body1`'s angular velocity.
5823
+ *
5824
+ * The motor drives: `body2.angularVel - ratio * body1.angularVel → rate`
5825
+ * @defaultValue `1.0`
5826
+ */
4133
5827
  get ratio(): number;
4134
5828
  set ratio(value: number);
4135
5829
  impulse(): MatMN;
@@ -4226,32 +5920,64 @@ declare class ZPP_LineJoint extends ZPP_Constraint {
4226
5920
  }
4227
5921
 
4228
5922
  /**
4229
- * Line joint — constrains body2's anchor to slide along a line
4230
- * defined by body1's anchor and direction.
5923
+ * Line joint — constrains `body2`'s anchor to slide along a line defined by
5924
+ * `body1`'s anchor and `direction`, within `[jointMin, jointMax]`.
5925
+ *
5926
+ * The direction is specified in `body1`'s local space. The joint allows one
5927
+ * translational degree of freedom (along the line) and removes the other.
5928
+ *
5929
+ * @example
5930
+ * ```ts
5931
+ * // Allow body2 to slide vertically relative to body1
5932
+ * const joint = new LineJoint(
5933
+ * body1, body2,
5934
+ * Vec2.weak(0, 0), // anchor on body1
5935
+ * Vec2.weak(0, 0), // anchor on body2
5936
+ * Vec2.weak(0, 1), // direction (local to body1)
5937
+ * -50, 50, // allowed travel range
5938
+ * );
5939
+ * joint.space = space;
5940
+ * ```
4231
5941
  *
4232
5942
  * Fully modernized — uses ZPP_LineJoint directly (extracted to TypeScript).
4233
5943
  */
4234
5944
  declare class LineJoint extends Constraint {
4235
5945
  zpp_inner: ZPP_LineJoint;
5946
+ /**
5947
+ * @param body1 - First body (defines the line), or `null` for a static world line.
5948
+ * @param body2 - Second body (slides along the line), or `null` for a static anchor.
5949
+ * @param anchor1 - Origin of the line in `body1`'s local space (disposed if weak).
5950
+ * @param anchor2 - Anchor on `body2` in `body2`'s local space (disposed if weak).
5951
+ * @param direction - Direction of the line in `body1`'s local space (disposed if weak).
5952
+ * @param jointMin - Minimum allowed displacement along the line.
5953
+ * @param jointMax - Maximum allowed displacement along the line.
5954
+ */
4236
5955
  constructor(body1: Body | null, body2: Body | null, anchor1: Vec2, anchor2: Vec2, direction: Vec2, jointMin: number, jointMax: number);
4237
5956
  /** @internal */
4238
5957
  static _wrap(inner: any): LineJoint;
5958
+ /** Body that defines the line's origin and direction. */
4239
5959
  get body1(): Body;
4240
5960
  set body1(value: Body | null);
4241
5961
  /** @internal */
4242
5962
  private _setBody1;
5963
+ /** Body whose anchor slides along the line. */
4243
5964
  get body2(): Body;
4244
5965
  set body2(value: Body | null);
4245
5966
  /** @internal */
4246
5967
  private _setBody2;
5968
+ /** Origin of the line on `body1` in local coordinates. */
4247
5969
  get anchor1(): Vec2;
4248
5970
  set anchor1(value: Vec2);
5971
+ /** Anchor point on `body2` in local coordinates. */
4249
5972
  get anchor2(): Vec2;
4250
5973
  set anchor2(value: Vec2);
5974
+ /** Direction of the line in `body1`'s local space. Does not need to be normalised. */
4251
5975
  get direction(): Vec2;
4252
5976
  set direction(value: Vec2);
5977
+ /** Minimum displacement along the line direction. */
4253
5978
  get jointMin(): number;
4254
5979
  set jointMin(value: number);
5980
+ /** Maximum displacement along the line direction. */
4255
5981
  get jointMax(): number;
4256
5982
  set jointMax(value: number);
4257
5983
  impulse(): MatMN;
@@ -4352,24 +6078,58 @@ declare class ZPP_PulleyJoint extends ZPP_Constraint {
4352
6078
  }
4353
6079
 
4354
6080
  /**
4355
- * Pulley joint — constrains the weighted sum of distances between
4356
- * four anchor points on four bodies.
6081
+ * Pulley joint — constrains the weighted sum of two distances to remain within
6082
+ * `[jointMin, jointMax]`:
6083
+ *
6084
+ * `jointMin ≤ distance(anchor1, anchor2) + ratio * distance(anchor3, anchor4) ≤ jointMax`
6085
+ *
6086
+ * This models a rope-and-pulley system where lifting one side lowers the other.
6087
+ * All four anchors are in the local space of their respective bodies.
6088
+ *
6089
+ * @example
6090
+ * ```ts
6091
+ * // Classic pulley: as body2 moves away from anchor1, body4 moves toward anchor3
6092
+ * const joint = new PulleyJoint(
6093
+ * body1, body2, body3, body4,
6094
+ * Vec2.weak(0,0), Vec2.weak(0,0),
6095
+ * Vec2.weak(0,0), Vec2.weak(0,0),
6096
+ * 0, 200, // total rope length
6097
+ * );
6098
+ * joint.space = space;
6099
+ * ```
4357
6100
  *
4358
6101
  * Fully modernized — uses ZPP_PulleyJoint directly (extracted to TypeScript).
4359
6102
  */
4360
6103
  declare class PulleyJoint extends Constraint {
4361
6104
  zpp_inner: ZPP_PulleyJoint;
6105
+ /**
6106
+ * @param body1 - First body (pulley side 1), or `null` for a static anchor.
6107
+ * @param body2 - Second body (pulley side 1), or `null` for a static anchor.
6108
+ * @param body3 - Third body (pulley side 2), or `null` for a static anchor.
6109
+ * @param body4 - Fourth body (pulley side 2), or `null` for a static anchor.
6110
+ * @param anchor1 - Anchor on `body1` in local space (disposed if weak).
6111
+ * @param anchor2 - Anchor on `body2` in local space (disposed if weak).
6112
+ * @param anchor3 - Anchor on `body3` in local space (disposed if weak).
6113
+ * @param anchor4 - Anchor on `body4` in local space (disposed if weak).
6114
+ * @param jointMin - Minimum allowed total rope length (must be `>= 0`).
6115
+ * @param jointMax - Maximum allowed total rope length (must be `>= jointMin`).
6116
+ * @param ratio - Weight of the second distance segment. Default `1.0`.
6117
+ */
4362
6118
  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);
4363
6119
  /** @internal Helper to set an anchor during construction. */
4364
6120
  private _setAnchorInit;
4365
6121
  /** @internal */
4366
6122
  static _wrap(inner: any): PulleyJoint;
6123
+ /** First body of the first rope segment. `null` = static world point. */
4367
6124
  get body1(): Body;
4368
6125
  set body1(value: Body | null);
6126
+ /** Second body of the first rope segment. `null` = static world point. */
4369
6127
  get body2(): Body;
4370
6128
  set body2(value: Body | null);
6129
+ /** First body of the second rope segment. `null` = static world point. */
4371
6130
  get body3(): Body;
4372
6131
  set body3(value: Body | null);
6132
+ /** Second body of the second rope segment. `null` = static world point. */
4373
6133
  get body4(): Body;
4374
6134
  set body4(value: Body | null);
4375
6135
  /** @internal */
@@ -4380,20 +6140,38 @@ declare class PulleyJoint extends Constraint {
4380
6140
  private _setBody3;
4381
6141
  /** @internal */
4382
6142
  private _setBody4;
6143
+ /** Anchor on `body1` in local coordinates. */
4383
6144
  get anchor1(): Vec2;
4384
6145
  set anchor1(value: Vec2);
6146
+ /** Anchor on `body2` in local coordinates. */
4385
6147
  get anchor2(): Vec2;
4386
6148
  set anchor2(value: Vec2);
6149
+ /** Anchor on `body3` in local coordinates. */
4387
6150
  get anchor3(): Vec2;
4388
6151
  set anchor3(value: Vec2);
6152
+ /** Anchor on `body4` in local coordinates. */
4389
6153
  get anchor4(): Vec2;
4390
6154
  set anchor4(value: Vec2);
6155
+ /** Minimum allowed total rope length (must be `>= 0`). */
4391
6156
  get jointMin(): number;
4392
6157
  set jointMin(value: number);
6158
+ /** Maximum allowed total rope length (must be `>= jointMin`). */
4393
6159
  get jointMax(): number;
4394
6160
  set jointMax(value: number);
6161
+ /**
6162
+ * Weight of the second rope segment in the total length sum.
6163
+ *
6164
+ * The constraint enforces: `distance(a1,a2) + ratio * distance(a3,a4)` within bounds.
6165
+ * @defaultValue `1.0`
6166
+ */
4395
6167
  get ratio(): number;
4396
6168
  set ratio(value: number);
6169
+ /**
6170
+ * Returns `true` when the total rope length is within bounds and no corrective
6171
+ * impulse was applied last step.
6172
+ *
6173
+ * @throws if any of the four bodies is `null`.
6174
+ */
4397
6175
  isSlack(): boolean;
4398
6176
  impulse(): MatMN;
4399
6177
  bodyImpulse(body: Body): Vec3;