@newkrok/nape-js 3.3.0 → 3.3.2

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.ts CHANGED
@@ -85,27 +85,104 @@ declare class Vec2 {
85
85
  /** @internal Opaque handle for any Haxe-compiled nape object. */
86
86
  type NapeInner = any;
87
87
 
88
+ /**
89
+ * ZPP_AABB — Internal axis-aligned bounding box for the nape physics engine.
90
+ *
91
+ * Stores min/max coordinates and provides intersection/combine/contain tests.
92
+ * Lazily creates Vec2 wrappers for the min and max points.
93
+ *
94
+ * Converted from nape-compiled.js lines 63546–63965, 134951.
95
+ */
96
+ type Any$4 = any;
97
+ declare class ZPP_AABB {
98
+ static zpp_pool: ZPP_AABB | null;
99
+ static __name__: string[];
100
+ static _nape: Any$4;
101
+ static _zpp: Any$4;
102
+ static _wrapFn: ((zpp: ZPP_AABB) => Any$4) | null;
103
+ _invalidate: ((self: ZPP_AABB) => void) | null;
104
+ _validate: (() => void) | null;
105
+ _immutable: boolean;
106
+ outer: Any$4;
107
+ next: ZPP_AABB | null;
108
+ minx: number;
109
+ miny: number;
110
+ maxx: number;
111
+ maxy: number;
112
+ wrap_min: Any$4;
113
+ wrap_max: Any$4;
114
+ __class__: Any$4;
115
+ /** Static factory with pooling. */
116
+ static get(minx: number, miny: number, maxx: number, maxy: number): ZPP_AABB;
117
+ validate(): void;
118
+ invalidate(): void;
119
+ wrapper(): Any$4;
120
+ alloc(): void;
121
+ free(): void;
122
+ copy(): ZPP_AABB;
123
+ width(): number;
124
+ height(): number;
125
+ perimeter(): number;
126
+ /** Helper: create a Vec2 wrapper from the compiled namespace pools. */
127
+ private static _makeVec2Wrapper;
128
+ getmin(): void;
129
+ dom_min(): void;
130
+ mod_min(min: Any$4): void;
131
+ getmax(): void;
132
+ dom_max(): void;
133
+ mod_max(max: Any$4): void;
134
+ intersectX(x: ZPP_AABB): boolean;
135
+ intersectY(x: ZPP_AABB): boolean;
136
+ intersect(x: ZPP_AABB): boolean;
137
+ combine(x: ZPP_AABB): void;
138
+ contains(x: ZPP_AABB): boolean;
139
+ containsPoint(v: {
140
+ x: number;
141
+ y: number;
142
+ }): boolean;
143
+ setCombine(a: ZPP_AABB, b: ZPP_AABB): void;
144
+ setExpand(a: ZPP_AABB, fatten: number): void;
145
+ setExpandPoint(x: number, y: number): void;
146
+ toString(): string;
147
+ }
148
+
88
149
  /**
89
150
  * Axis-aligned bounding box defined by min/max corners or x/y/width/height.
151
+ *
152
+ * Internally wraps a ZPP_AABB and is registered as the public
153
+ * `nape.geom.AABB` class in the compiled namespace.
154
+ *
155
+ * Converted from nape-compiled.js lines 14950–15653.
90
156
  */
91
157
  declare class AABB {
92
- /** @internal */
93
- readonly _inner: NapeInner;
158
+ static __name__: string[];
159
+ /** @internal The internal ZPP_AABB this wrapper owns. */
160
+ zpp_inner: ZPP_AABB;
161
+ /**
162
+ * Backward-compatible accessor — returns `this` so that compiled engine
163
+ * code that receives `aabb._inner` can still access `zpp_inner`.
164
+ * @internal
165
+ */
166
+ get _inner(): NapeInner;
94
167
  constructor(x?: number, y?: number, width?: number, height?: number);
95
- /** @internal */
96
- static _wrap(inner: NapeInner): AABB;
97
- get min(): Vec2;
98
- set min(value: Vec2);
99
- get max(): Vec2;
100
- set max(value: Vec2);
168
+ /** @internal Wrap a ZPP_AABB (or legacy compiled AABB) with caching. */
169
+ static _wrap(inner: any): AABB;
101
170
  get x(): number;
102
- set x(value: number);
171
+ set x(x: number);
103
172
  get y(): number;
104
- set y(value: number);
173
+ set y(y: number);
105
174
  get width(): number;
106
- set width(value: number);
175
+ set width(width: number);
107
176
  get height(): number;
108
- set height(value: number);
177
+ set height(height: number);
178
+ get min(): any;
179
+ set min(min: any);
180
+ get max(): any;
181
+ set max(max: any);
182
+ /** @internal Assign source Vec2 values to target Vec2 wrapper. */
183
+ private _assignVec2;
184
+ /** @internal Dispose a weak Vec2 back to the pool. */
185
+ private _disposeVec2;
109
186
  copy(): AABB;
110
187
  toString(): string;
111
188
  }
@@ -163,15 +240,88 @@ declare class NapeList<T> implements Iterable<T> {
163
240
  toString(): string;
164
241
  }
165
242
 
243
+ /**
244
+ * ZPP_Material — Internal material representation for the nape physics engine.
245
+ *
246
+ * Stores physical material properties (friction, elasticity, density) and
247
+ * manages the list of shapes that reference this material for invalidation.
248
+ *
249
+ * Converted from nape-compiled.js lines 87523–87601, 135477–135481.
250
+ */
251
+ type Any$3 = any;
252
+ declare class ZPP_Material {
253
+ static zpp_pool: ZPP_Material | null;
254
+ static WAKE: number;
255
+ static PROPS: number;
256
+ static ANGDRAG: number;
257
+ static ARBITERS: number;
258
+ static __name__: string[];
259
+ /**
260
+ * Namespace references, set by the compiled module after import.
261
+ * _nape = the `nape` public namespace (for wrapper creation)
262
+ * _zpp = the `zpp_nape` internal namespace (for ZNPList_ZPP_Shape)
263
+ */
264
+ static _nape: Any$3;
265
+ static _zpp: Any$3;
266
+ /**
267
+ * Wrapper factory callback, registered by the modernized Material class.
268
+ * When set, wrapper() uses this instead of creating a compiled Material.
269
+ */
270
+ static _wrapFn: ((zpp: ZPP_Material) => Any$3) | null;
271
+ elasticity: number;
272
+ dynamicFriction: number;
273
+ staticFriction: number;
274
+ density: number;
275
+ rollingFriction: number;
276
+ shapes: Any$3;
277
+ wrap_shapes: Any$3;
278
+ outer: Any$3;
279
+ userData: Any$3;
280
+ next: ZPP_Material | null;
281
+ __class__: Any$3;
282
+ constructor();
283
+ /** Create/return the public nape.phys.Material wrapper for this internal object. */
284
+ wrapper(): Any$3;
285
+ /** Called when this object is returned to the pool. */
286
+ free(): void;
287
+ /** Called when this object is taken from the pool. */
288
+ alloc(): void;
289
+ /** Initialize the shapes list (called during feature construction). */
290
+ feature_cons(): void;
291
+ /** Register a shape that uses this material. */
292
+ addShape(shape: Any$3): void;
293
+ /** Unregister a shape that no longer uses this material. */
294
+ remShape(shape: Any$3): void;
295
+ /** Create a copy with the same property values. */
296
+ copy(): ZPP_Material;
297
+ /** Copy all property values from another ZPP_Material. */
298
+ set(x: ZPP_Material): void;
299
+ /** Notify all shapes using this material that properties changed. */
300
+ invalidate(x: number): void;
301
+ }
302
+
166
303
  /**
167
304
  * Physical material properties applied to shapes.
305
+ *
306
+ * Controls elasticity (bounciness), friction coefficients, density, and
307
+ * rolling friction. Internally wraps a ZPP_Material and is registered as
308
+ * the public `nape.phys.Material` class in the compiled namespace.
309
+ *
310
+ * Converted from nape-compiled.js lines 38254–38573.
168
311
  */
169
312
  declare class Material {
170
- /** @internal */
171
- readonly _inner: NapeInner;
313
+ static __name__: string[];
314
+ /** @internal The internal ZPP_Material this wrapper owns. */
315
+ zpp_inner: ZPP_Material;
316
+ /**
317
+ * Backward-compatible accessor — returns `this` so that compiled engine
318
+ * code that receives `material._inner` can still access `zpp_inner`.
319
+ * @internal
320
+ */
321
+ get _inner(): NapeInner;
172
322
  constructor(elasticity?: number, dynamicFriction?: number, staticFriction?: number, density?: number, rollingFriction?: number);
173
- /** @internal */
174
- static _wrap(inner: NapeInner): Material;
323
+ /** @internal Wrap a ZPP_Material (or legacy compiled Material) with caching. */
324
+ static _wrap(inner: any): Material;
175
325
  get elasticity(): number;
176
326
  set elasticity(value: number);
177
327
  get dynamicFriction(): number;
@@ -185,38 +335,163 @@ declare class Material {
185
335
  get userData(): Record<string, unknown>;
186
336
  copy(): Material;
187
337
  toString(): string;
338
+ static wood(): Material;
339
+ static steel(): Material;
340
+ static ice(): Material;
341
+ static rubber(): Material;
342
+ static glass(): Material;
343
+ static sand(): Material;
344
+ }
345
+
346
+ /**
347
+ * ZPP_FluidProperties — Internal fluid properties for the nape physics engine.
348
+ *
349
+ * Stores density, viscosity, and per-fluid gravity override.
350
+ * Manages the list of shapes that reference these properties for invalidation.
351
+ *
352
+ * Converted from nape-compiled.js lines 87335–87523, 135403.
353
+ */
354
+ type Any$2 = any;
355
+ declare class ZPP_FluidProperties {
356
+ static zpp_pool: ZPP_FluidProperties | null;
357
+ static __name__: string[];
358
+ static _nape: Any$2;
359
+ static _zpp: Any$2;
360
+ static _wrapFn: ((zpp: ZPP_FluidProperties) => Any$2) | null;
361
+ viscosity: number;
362
+ density: number;
363
+ gravityx: number;
364
+ gravityy: number;
365
+ wrap_gravity: Any$2;
366
+ shapes: Any$2;
367
+ wrap_shapes: Any$2;
368
+ outer: Any$2;
369
+ userData: Any$2;
370
+ next: ZPP_FluidProperties | null;
371
+ __class__: Any$2;
372
+ constructor();
373
+ /** Create/return the public nape.phys.FluidProperties wrapper. */
374
+ wrapper(): Any$2;
375
+ free(): void;
376
+ alloc(): void;
377
+ feature_cons(): void;
378
+ addShape(shape: Any$2): void;
379
+ remShape(shape: Any$2): void;
380
+ /** Copy with object pooling. */
381
+ copy(): ZPP_FluidProperties;
382
+ /** Called when gravity Vec2 wrapper is invalidated (user set new gravity). */
383
+ gravity_invalidate(x: Any$2): void;
384
+ /** Sync the gravity Vec2 wrapper with internal values. */
385
+ gravity_validate(): void;
386
+ /** Lazily create and return the gravity Vec2 wrapper. */
387
+ getgravity(): void;
388
+ /** Notify all shapes that fluid properties changed. */
389
+ invalidate(): void;
188
390
  }
189
391
 
190
392
  /**
191
393
  * Fluid properties for shapes that act as fluid regions.
394
+ *
395
+ * Controls density, viscosity, and per-fluid gravity override.
396
+ * Internally wraps a ZPP_FluidProperties and is registered as
397
+ * the public `nape.phys.FluidProperties` class in the compiled namespace.
398
+ *
399
+ * Converted from nape-compiled.js lines 37002–37511.
192
400
  */
193
401
  declare class FluidProperties {
194
- /** @internal */
195
- readonly _inner: NapeInner;
402
+ static __name__: string[];
403
+ /** @internal The internal ZPP_FluidProperties this wrapper owns. */
404
+ zpp_inner: ZPP_FluidProperties;
405
+ /**
406
+ * Backward-compatible accessor — returns `this` so that compiled engine
407
+ * code that receives `fluidProps._inner` can still access `zpp_inner`.
408
+ * @internal
409
+ */
410
+ get _inner(): NapeInner;
196
411
  constructor(density?: number, viscosity?: number);
197
- /** @internal */
198
- static _wrap(inner: NapeInner): FluidProperties;
412
+ /** @internal Wrap a ZPP_FluidProperties (or legacy compiled FluidProperties) with caching. */
413
+ static _wrap(inner: any): FluidProperties;
199
414
  get density(): number;
200
415
  set density(value: number);
201
416
  get viscosity(): number;
202
417
  set viscosity(value: number);
203
- get gravity(): Vec2;
204
- set gravity(value: Vec2);
418
+ get gravity(): any;
419
+ set gravity(gravity: any);
205
420
  get userData(): Record<string, unknown>;
421
+ get shapes(): any;
206
422
  copy(): FluidProperties;
207
423
  toString(): string;
208
424
  }
209
425
 
426
+ /**
427
+ * ZPP_InteractionFilter — Internal interaction filter for the nape physics engine.
428
+ *
429
+ * Stores collision/sensor/fluid group and mask bitmasks that determine
430
+ * which shapes interact with each other.
431
+ *
432
+ * Converted from nape-compiled.js lines 63255–63366, 135329.
433
+ */
434
+ type Any$1 = any;
435
+ declare class ZPP_InteractionFilter {
436
+ static zpp_pool: ZPP_InteractionFilter | null;
437
+ static __name__: string[];
438
+ static _nape: Any$1;
439
+ static _zpp: Any$1;
440
+ static _wrapFn: ((zpp: ZPP_InteractionFilter) => Any$1) | null;
441
+ collisionGroup: number;
442
+ collisionMask: number;
443
+ sensorGroup: number;
444
+ sensorMask: number;
445
+ fluidGroup: number;
446
+ fluidMask: number;
447
+ shapes: Any$1;
448
+ wrap_shapes: Any$1;
449
+ outer: Any$1;
450
+ userData: Any$1;
451
+ next: ZPP_InteractionFilter | null;
452
+ __class__: Any$1;
453
+ constructor();
454
+ /** Create/return the public nape.dynamics.InteractionFilter wrapper. */
455
+ wrapper(): Any$1;
456
+ free(): void;
457
+ alloc(): void;
458
+ feature_cons(): void;
459
+ addShape(shape: Any$1): void;
460
+ remShape(shape: Any$1): void;
461
+ /** Create a copy with object pooling. */
462
+ copy(): ZPP_InteractionFilter;
463
+ /** Test whether two filters allow collision between their shapes. */
464
+ shouldCollide(x: ZPP_InteractionFilter): boolean;
465
+ /** Test whether two filters allow sensor interaction. */
466
+ shouldSense(x: ZPP_InteractionFilter): boolean;
467
+ /** Test whether two filters allow fluid interaction. */
468
+ shouldFlow(x: ZPP_InteractionFilter): boolean;
469
+ /** Notify all shapes that the filter changed. */
470
+ invalidate(): void;
471
+ }
472
+
210
473
  /**
211
474
  * Bit-mask based interaction filter for controlling which shapes
212
475
  * collide, sense, or interact as fluids.
476
+ *
477
+ * Internally wraps a ZPP_InteractionFilter and is registered as
478
+ * the public `nape.dynamics.InteractionFilter` class in the compiled namespace.
479
+ *
480
+ * Converted from nape-compiled.js lines 14361–14640.
213
481
  */
214
482
  declare class InteractionFilter {
215
- /** @internal */
216
- readonly _inner: NapeInner;
483
+ static __name__: string[];
484
+ /** @internal The internal ZPP_InteractionFilter this wrapper owns. */
485
+ zpp_inner: ZPP_InteractionFilter;
486
+ /**
487
+ * Backward-compatible accessor — returns `this` so that compiled engine
488
+ * code that receives `filter._inner` can still access `zpp_inner`.
489
+ * @internal
490
+ */
491
+ get _inner(): NapeInner;
217
492
  constructor(collisionGroup?: number, collisionMask?: number, sensorGroup?: number, sensorMask?: number, fluidGroup?: number, fluidMask?: number);
218
- /** @internal */
219
- static _wrap(inner: NapeInner): InteractionFilter;
493
+ /** @internal Wrap a ZPP_InteractionFilter (or legacy compiled InteractionFilter) with caching. */
494
+ static _wrap(inner: any): InteractionFilter;
220
495
  get collisionGroup(): number;
221
496
  set collisionGroup(value: number);
222
497
  get collisionMask(): number;
@@ -230,9 +505,10 @@ declare class InteractionFilter {
230
505
  get fluidMask(): number;
231
506
  set fluidMask(value: number);
232
507
  get userData(): Record<string, unknown>;
233
- shouldCollide(other: InteractionFilter): boolean;
234
- shouldSense(other: InteractionFilter): boolean;
235
- shouldFlow(other: InteractionFilter): boolean;
508
+ get shapes(): any;
509
+ shouldCollide(filter: InteractionFilter): boolean;
510
+ shouldSense(filter: InteractionFilter): boolean;
511
+ shouldFlow(filter: InteractionFilter): boolean;
236
512
  copy(): InteractionFilter;
237
513
  toString(): string;
238
514
  }
@@ -555,20 +831,73 @@ declare class Polygon extends Shape {
555
831
  validity(): NapeInner;
556
832
  }
557
833
 
834
+ /**
835
+ * ZPP_InteractionGroup — Internal interaction group for the nape physics engine.
836
+ *
837
+ * Hierarchical groups that can override interaction filters. When two shapes
838
+ * share a common group with `ignore = true`, their interaction is suppressed.
839
+ *
840
+ * Converted from nape-compiled.js lines 63367–63463, 135330–135331.
841
+ */
842
+ type Any = any;
843
+ declare class ZPP_InteractionGroup {
844
+ static SHAPE: number;
845
+ static BODY: number;
846
+ static __name__: string[];
847
+ static _zpp: Any;
848
+ static _wrapFn: ((zpp: ZPP_InteractionGroup) => Any) | null;
849
+ outer: Any;
850
+ ignore: boolean;
851
+ group: ZPP_InteractionGroup | null;
852
+ groups: Any;
853
+ wrap_groups: Any;
854
+ interactors: Any;
855
+ wrap_interactors: Any;
856
+ depth: number;
857
+ __class__: Any;
858
+ constructor();
859
+ /** Set or change the parent group. */
860
+ setGroup(group: ZPP_InteractionGroup | null): void;
861
+ /** Wake all interactors and propagate to child groups. */
862
+ invalidate(force?: boolean): void;
863
+ /** Add a child group. */
864
+ addGroup(group: ZPP_InteractionGroup): void;
865
+ /** Remove a child group. */
866
+ remGroup(group: ZPP_InteractionGroup): void;
867
+ /** Register an interactor in this group. */
868
+ addInteractor(intx: Any): void;
869
+ /** Unregister an interactor from this group. */
870
+ remInteractor(intx: Any, flag?: number): void;
871
+ }
872
+
558
873
  /**
559
874
  * Hierarchical interaction group for controlling interactions
560
875
  * between sets of interactors.
876
+ *
877
+ * Internally wraps a ZPP_InteractionGroup and is registered as
878
+ * the public `nape.dynamics.InteractionGroup` class in the compiled namespace.
879
+ *
880
+ * Converted from nape-compiled.js lines 14641–14733.
561
881
  */
562
882
  declare class InteractionGroup {
563
- /** @internal */
564
- readonly _inner: NapeInner;
883
+ static __name__: string[];
884
+ /** @internal The internal ZPP_InteractionGroup this wrapper owns. */
885
+ zpp_inner: ZPP_InteractionGroup;
886
+ /**
887
+ * Backward-compatible accessor — returns `this` so that compiled engine
888
+ * code that receives `group._inner` can still access `zpp_inner`.
889
+ * @internal
890
+ */
891
+ get _inner(): NapeInner;
565
892
  constructor(ignore?: boolean);
566
- /** @internal */
567
- static _wrap(inner: NapeInner): InteractionGroup;
568
- get group(): InteractionGroup;
893
+ /** @internal Wrap a ZPP_InteractionGroup (or legacy compiled InteractionGroup) with caching. */
894
+ static _wrap(inner: any): InteractionGroup;
895
+ get group(): InteractionGroup | null;
569
896
  set group(value: InteractionGroup | null);
570
897
  get ignore(): boolean;
571
898
  set ignore(value: boolean);
899
+ get interactors(): any;
900
+ get groups(): any;
572
901
  toString(): string;
573
902
  }
574
903