@newkrok/nape-js 3.3.3 → 3.3.4
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.cjs +4756 -8715
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +220 -33
- package/dist/index.d.ts +220 -33
- package/dist/index.js +4755 -8715
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -15,76 +15,263 @@
|
|
|
15
15
|
*/
|
|
16
16
|
declare function getNape(): any;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* ZPP_Vec2 — Internal 2D vector AND intrusive linked list for the nape physics engine.
|
|
20
|
+
*
|
|
21
|
+
* Serves three roles simultaneously (Haxe ZNPList template expansion):
|
|
22
|
+
* 1. 2D vector data: x, y coordinates
|
|
23
|
+
* 2. Intrusive linked list container: add/remove/insert/pop (head via `next`)
|
|
24
|
+
* 3. Pooled object with wrapper/validation pattern
|
|
25
|
+
*
|
|
26
|
+
* Converted from nape-compiled.js lines 83820–84273, 134996.
|
|
27
|
+
*/
|
|
28
|
+
type Any$6 = any;
|
|
29
|
+
declare class ZPP_Vec2 {
|
|
30
|
+
static zpp_pool: ZPP_Vec2 | null;
|
|
31
|
+
static __name__: string[];
|
|
32
|
+
static _nape: Any$6;
|
|
33
|
+
static _zpp: Any$6;
|
|
34
|
+
static _wrapFn: ((zpp: ZPP_Vec2) => Any$6) | null;
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
next: ZPP_Vec2 | null;
|
|
38
|
+
length: number;
|
|
39
|
+
modified: boolean;
|
|
40
|
+
pushmod: boolean;
|
|
41
|
+
_inuse: boolean;
|
|
42
|
+
weak: boolean;
|
|
43
|
+
outer: Any$6;
|
|
44
|
+
_immutable: boolean;
|
|
45
|
+
_isimmutable: (() => void) | null;
|
|
46
|
+
_validate: (() => void) | null;
|
|
47
|
+
_invalidate: ((self: ZPP_Vec2) => void) | null;
|
|
48
|
+
__class__: Any$6;
|
|
49
|
+
/** Static factory with optional pooling and immutability. */
|
|
50
|
+
static get(x: number, y: number, immutable?: boolean): ZPP_Vec2;
|
|
51
|
+
validate(): void;
|
|
52
|
+
invalidate(): void;
|
|
53
|
+
immutable(): void;
|
|
54
|
+
wrapper(): Any$6;
|
|
55
|
+
free(): void;
|
|
56
|
+
alloc(): void;
|
|
57
|
+
elem(): ZPP_Vec2;
|
|
58
|
+
begin(): ZPP_Vec2 | null;
|
|
59
|
+
setbegin(i: ZPP_Vec2 | null): void;
|
|
60
|
+
add(o: ZPP_Vec2): ZPP_Vec2;
|
|
61
|
+
inlined_add(o: ZPP_Vec2): ZPP_Vec2;
|
|
62
|
+
addAll(x: ZPP_Vec2): void;
|
|
63
|
+
insert(cur: ZPP_Vec2 | null, o: ZPP_Vec2): ZPP_Vec2;
|
|
64
|
+
inlined_insert(cur: ZPP_Vec2 | null, o: ZPP_Vec2): ZPP_Vec2;
|
|
65
|
+
pop(): void;
|
|
66
|
+
inlined_pop(): void;
|
|
67
|
+
pop_unsafe(): ZPP_Vec2;
|
|
68
|
+
inlined_pop_unsafe(): ZPP_Vec2;
|
|
69
|
+
remove(obj: ZPP_Vec2): void;
|
|
70
|
+
try_remove(obj: ZPP_Vec2): boolean;
|
|
71
|
+
inlined_remove(obj: ZPP_Vec2): void;
|
|
72
|
+
inlined_try_remove(obj: ZPP_Vec2): boolean;
|
|
73
|
+
erase(pre: ZPP_Vec2 | null): ZPP_Vec2 | null;
|
|
74
|
+
inlined_erase(pre: ZPP_Vec2 | null): ZPP_Vec2 | null;
|
|
75
|
+
splice(pre: ZPP_Vec2, n: number): ZPP_Vec2 | null;
|
|
76
|
+
clear(): void;
|
|
77
|
+
inlined_clear(): void;
|
|
78
|
+
reverse(): void;
|
|
79
|
+
empty(): boolean;
|
|
80
|
+
size(): number;
|
|
81
|
+
has(obj: ZPP_Vec2): boolean;
|
|
82
|
+
inlined_has(obj: ZPP_Vec2): boolean;
|
|
83
|
+
front(): ZPP_Vec2 | null;
|
|
84
|
+
back(): ZPP_Vec2 | null;
|
|
85
|
+
iterator_at(ind: number): ZPP_Vec2 | null;
|
|
86
|
+
at(ind: number): ZPP_Vec2 | null;
|
|
87
|
+
copy(): ZPP_Vec2;
|
|
88
|
+
toString(): string;
|
|
89
|
+
}
|
|
90
|
+
|
|
18
91
|
/**
|
|
19
92
|
* 2D vector used for positions, velocities, forces, and other 2D quantities.
|
|
20
93
|
*
|
|
21
|
-
*
|
|
94
|
+
* Supports object pooling via `Vec2.get()` / `dispose()`, weak references
|
|
95
|
+
* that auto-dispose after a single use, and immutability guards.
|
|
96
|
+
*
|
|
97
|
+
* Converted from nape-compiled.js lines 23448–27180.
|
|
22
98
|
*/
|
|
23
99
|
declare class Vec2 {
|
|
24
|
-
|
|
25
|
-
|
|
100
|
+
static __name__: string[];
|
|
101
|
+
/** @internal The internal ZPP_Vec2 this wrapper owns. */
|
|
102
|
+
zpp_inner: ZPP_Vec2;
|
|
103
|
+
/** @internal Public Vec2 pool link. */
|
|
104
|
+
zpp_pool: Vec2 | null;
|
|
105
|
+
/** @internal Whether this Vec2 has been disposed. */
|
|
106
|
+
zpp_disp: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Backward-compatible accessor — returns `this` so that compiled engine
|
|
109
|
+
* code that receives `vec._inner` can still access `zpp_inner`.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
get _inner(): NapeInner;
|
|
26
113
|
constructor(x?: number, y?: number);
|
|
27
|
-
/** @internal
|
|
28
|
-
|
|
114
|
+
/** @internal Check that this Vec2 has not been disposed. */
|
|
115
|
+
private _checkDisposed;
|
|
116
|
+
/** @internal Check immutability. */
|
|
117
|
+
private _checkImmutable;
|
|
118
|
+
/** @internal Validate (lazy evaluation callback). */
|
|
119
|
+
private _validate;
|
|
120
|
+
/** @internal Invalidate (notify dependents). */
|
|
121
|
+
private _invalidate;
|
|
122
|
+
/** @internal Dispose a weak Vec2 argument after use. */
|
|
123
|
+
private static _disposeWeak;
|
|
124
|
+
/**
|
|
125
|
+
* @internal Set x and y on zpp_inner with validation/invalidation.
|
|
126
|
+
* Only invalidates if values actually changed.
|
|
127
|
+
*/
|
|
128
|
+
private _setXY;
|
|
129
|
+
/** @internal Get a Vec2 from the public pool or create a new one. */
|
|
130
|
+
private static _poolGet;
|
|
131
|
+
/** @internal Wrap a ZPP_Vec2 (or legacy compiled Vec2) with caching. */
|
|
132
|
+
static _wrap(inner: any): Vec2;
|
|
133
|
+
/** Obtain a Vec2 from the object pool (or create a new one). */
|
|
134
|
+
static get(x?: number, y?: number, weak?: boolean): Vec2;
|
|
135
|
+
/** Obtain a weak Vec2 that auto-disposes after a single use. */
|
|
136
|
+
static weak(x?: number, y?: number): Vec2;
|
|
137
|
+
/** Create a Vec2 from polar coordinates. */
|
|
138
|
+
static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
|
|
139
|
+
/** Squared distance between two Vec2s. */
|
|
140
|
+
static dsq(a: Vec2, b: Vec2): number;
|
|
141
|
+
/** Euclidean distance between two Vec2s. */
|
|
142
|
+
static distance(a: Vec2, b: Vec2): number;
|
|
29
143
|
get x(): number;
|
|
30
144
|
set x(value: number);
|
|
31
145
|
get y(): number;
|
|
32
146
|
set y(value: number);
|
|
33
|
-
/** Magnitude of the vector.
|
|
147
|
+
/** Magnitude of the vector. */
|
|
34
148
|
get length(): number;
|
|
149
|
+
/** Setting length scales the vector to the given magnitude. */
|
|
35
150
|
set length(value: number);
|
|
36
151
|
/** Angle of the vector in radians (measured from the +x axis). */
|
|
37
152
|
get angle(): number;
|
|
153
|
+
/** Setting angle preserves magnitude but rotates to the given angle. */
|
|
38
154
|
set angle(value: number);
|
|
39
155
|
/** Squared length — avoids a square root when only comparison is needed. */
|
|
40
156
|
lsq(): number;
|
|
41
|
-
/** Copy values from another vector into this one (in-place). */
|
|
42
|
-
set(
|
|
43
|
-
/** Set both components at once (in-place). */
|
|
157
|
+
/** Copy values from another vector into this one (in-place). Returns this. */
|
|
158
|
+
set(vector: Vec2): this;
|
|
159
|
+
/** Set both components at once (in-place). Returns this. */
|
|
44
160
|
setxy(x: number, y: number): this;
|
|
45
161
|
/** Return a new copy of this vector. */
|
|
46
162
|
copy(weak?: boolean): Vec2;
|
|
47
|
-
/** Rotate this vector by the given angle in radians (in-place). */
|
|
163
|
+
/** Rotate this vector by the given angle in radians (in-place). Returns this. */
|
|
48
164
|
rotate(angle: number): this;
|
|
49
165
|
/** Reflect this vector about the given axis vector (returns new Vec2). */
|
|
50
|
-
reflect(
|
|
51
|
-
/** Normalize this vector to unit length (in-place). Returns
|
|
52
|
-
normalise():
|
|
166
|
+
reflect(vec: Vec2, weak?: boolean): Vec2;
|
|
167
|
+
/** Normalize this vector to unit length (in-place). Returns this. */
|
|
168
|
+
normalise(): this;
|
|
53
169
|
/** Return a new unit-length vector with the same direction. */
|
|
54
170
|
unit(weak?: boolean): Vec2;
|
|
55
171
|
/** Return a new vector = this + other. */
|
|
56
|
-
add(
|
|
172
|
+
add(vector: Vec2, weak?: boolean): Vec2;
|
|
57
173
|
/** Return a new vector = this + other * scalar. */
|
|
58
|
-
addMul(
|
|
59
|
-
/** Return a new vector = this
|
|
60
|
-
sub(
|
|
174
|
+
addMul(vector: Vec2, scalar: number, weak?: boolean): Vec2;
|
|
175
|
+
/** Return a new vector = this - other. */
|
|
176
|
+
sub(vector: Vec2, weak?: boolean): Vec2;
|
|
61
177
|
/** Return a new vector = this * scalar. */
|
|
62
178
|
mul(scalar: number, weak?: boolean): Vec2;
|
|
63
|
-
/** this += other (in-place). */
|
|
64
|
-
addeq(
|
|
65
|
-
/** this -= other (in-place). */
|
|
66
|
-
subeq(
|
|
67
|
-
/** this *= scalar (in-place). */
|
|
179
|
+
/** this += other (in-place). Returns this. */
|
|
180
|
+
addeq(vector: Vec2): this;
|
|
181
|
+
/** this -= other (in-place). Returns this. */
|
|
182
|
+
subeq(vector: Vec2): this;
|
|
183
|
+
/** this *= scalar (in-place). Returns this. */
|
|
68
184
|
muleq(scalar: number): this;
|
|
69
185
|
/** Dot product of this and other. */
|
|
70
|
-
dot(
|
|
71
|
-
/** 2D cross product (returns scalar: this.x*other.y
|
|
72
|
-
cross(
|
|
73
|
-
/** Return the perpendicular vector (rotated
|
|
186
|
+
dot(vector: Vec2): number;
|
|
187
|
+
/** 2D cross product (returns scalar: this.x*other.y - this.y*other.x). */
|
|
188
|
+
cross(vector: Vec2): number;
|
|
189
|
+
/** Return the perpendicular vector (rotated 90deg counter-clockwise). */
|
|
74
190
|
perp(weak?: boolean): Vec2;
|
|
75
191
|
/** Release this vector back to the object pool. */
|
|
76
192
|
dispose(): void;
|
|
77
193
|
toString(): string;
|
|
78
|
-
/** Obtain a Vec2 from the object pool (or create a new one). */
|
|
79
|
-
static get(x?: number, y?: number, weak?: boolean): Vec2;
|
|
80
|
-
/** Obtain a weak Vec2 that auto-disposes after a single use. */
|
|
81
|
-
static weak(x?: number, y?: number): Vec2;
|
|
82
|
-
/** Create a Vec2 from polar coordinates. */
|
|
83
|
-
static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
|
|
84
194
|
}
|
|
85
195
|
/** @internal Opaque handle for any Haxe-compiled nape object. */
|
|
86
196
|
type NapeInner = any;
|
|
87
197
|
|
|
198
|
+
/**
|
|
199
|
+
* ZPP_Vec3 — Internal 3D vector for the nape physics engine.
|
|
200
|
+
*
|
|
201
|
+
* Simple x, y, z data container with optional validation callback.
|
|
202
|
+
* Used internally for constraint anchor points and similar 3-component values.
|
|
203
|
+
*
|
|
204
|
+
* Converted from nape-compiled.js lines 83412–83434.
|
|
205
|
+
*/
|
|
206
|
+
type Any$5 = any;
|
|
207
|
+
declare class ZPP_Vec3 {
|
|
208
|
+
static __name__: string[];
|
|
209
|
+
static _zpp: Any$5;
|
|
210
|
+
static _wrapFn: ((zpp: ZPP_Vec3) => Any$5) | null;
|
|
211
|
+
outer: Any$5;
|
|
212
|
+
x: number;
|
|
213
|
+
y: number;
|
|
214
|
+
z: number;
|
|
215
|
+
immutable: boolean;
|
|
216
|
+
_validate: (() => void) | null;
|
|
217
|
+
__class__: Any$5;
|
|
218
|
+
validate(): void;
|
|
219
|
+
wrapper(): Any$5;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 3D vector used for constraint impulses and other 3-component values.
|
|
224
|
+
*
|
|
225
|
+
* Supports object pooling via `Vec3.get()` / `dispose()`.
|
|
226
|
+
*
|
|
227
|
+
* Converted from nape-compiled.js lines 24120–25040.
|
|
228
|
+
*/
|
|
229
|
+
declare class Vec3 {
|
|
230
|
+
static __name__: string[];
|
|
231
|
+
/** @internal The internal ZPP_Vec3 this wrapper owns. */
|
|
232
|
+
zpp_inner: ZPP_Vec3;
|
|
233
|
+
/** @internal Public Vec3 pool link. */
|
|
234
|
+
zpp_pool: Vec3 | null;
|
|
235
|
+
/** @internal Whether this Vec3 has been disposed. */
|
|
236
|
+
zpp_disp: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Backward-compatible accessor — returns `this` so that compiled engine
|
|
239
|
+
* code that receives `v3._inner` can still access `zpp_inner`.
|
|
240
|
+
* @internal
|
|
241
|
+
*/
|
|
242
|
+
get _inner(): NapeInner;
|
|
243
|
+
constructor(x?: number, y?: number, z?: number);
|
|
244
|
+
/** @internal Check that this Vec3 has not been disposed. */
|
|
245
|
+
private _checkDisposed;
|
|
246
|
+
/** @internal Check immutability. */
|
|
247
|
+
private _checkImmutable;
|
|
248
|
+
/** @internal Wrap a ZPP_Vec3 (or legacy compiled Vec3) with caching. */
|
|
249
|
+
static _wrap(inner: any): Vec3;
|
|
250
|
+
/** Obtain a Vec3 from the object pool (or create a new one). */
|
|
251
|
+
static get(x?: number, y?: number, z?: number): Vec3;
|
|
252
|
+
get x(): number;
|
|
253
|
+
set x(value: number);
|
|
254
|
+
get y(): number;
|
|
255
|
+
set y(value: number);
|
|
256
|
+
get z(): number;
|
|
257
|
+
set z(value: number);
|
|
258
|
+
/** Magnitude of the 3D vector. */
|
|
259
|
+
get length(): number;
|
|
260
|
+
/** Setting length scales the vector to the given magnitude. */
|
|
261
|
+
set length(value: number);
|
|
262
|
+
/** Squared length — avoids a square root when only comparison is needed. */
|
|
263
|
+
lsq(): number;
|
|
264
|
+
/** Copy values from another Vec3 into this one (in-place). Returns this. */
|
|
265
|
+
set(vector: Vec3): this;
|
|
266
|
+
/** Set all three components at once (in-place). Returns this. */
|
|
267
|
+
setxyz(x: number, y: number, z: number): this;
|
|
268
|
+
/** Return the x,y components as a Vec2. */
|
|
269
|
+
xy(weak?: boolean): Vec2;
|
|
270
|
+
/** Release this Vec3 back to the object pool. */
|
|
271
|
+
dispose(): void;
|
|
272
|
+
toString(): string;
|
|
273
|
+
}
|
|
274
|
+
|
|
88
275
|
/**
|
|
89
276
|
* ZPP_AABB — Internal axis-aligned bounding box for the nape physics engine.
|
|
90
277
|
*
|
|
@@ -1166,4 +1353,4 @@ declare class PulleyJoint extends Constraint {
|
|
|
1166
1353
|
set ratio(value: number);
|
|
1167
1354
|
}
|
|
1168
1355
|
|
|
1169
|
-
export { AABB, AngleJoint, Body, BodyListener, BodyType, CbEvent, CbType, Circle, Constraint, ConstraintListener, DistanceJoint, FluidProperties, InteractionFilter, InteractionGroup, InteractionListener, InteractionType, LineJoint, Listener, Material, MotorJoint, NapeList, OptionType, PivotJoint, Polygon, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, Vec2, WeldJoint, getNape };
|
|
1356
|
+
export { AABB, AngleJoint, Body, BodyListener, BodyType, CbEvent, CbType, Circle, Constraint, ConstraintListener, DistanceJoint, FluidProperties, InteractionFilter, InteractionGroup, InteractionListener, InteractionType, LineJoint, Listener, Material, MotorJoint, NapeList, OptionType, PivotJoint, Polygon, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, Vec2, Vec3, WeldJoint, getNape };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,76 +15,263 @@
|
|
|
15
15
|
*/
|
|
16
16
|
declare function getNape(): any;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* ZPP_Vec2 — Internal 2D vector AND intrusive linked list for the nape physics engine.
|
|
20
|
+
*
|
|
21
|
+
* Serves three roles simultaneously (Haxe ZNPList template expansion):
|
|
22
|
+
* 1. 2D vector data: x, y coordinates
|
|
23
|
+
* 2. Intrusive linked list container: add/remove/insert/pop (head via `next`)
|
|
24
|
+
* 3. Pooled object with wrapper/validation pattern
|
|
25
|
+
*
|
|
26
|
+
* Converted from nape-compiled.js lines 83820–84273, 134996.
|
|
27
|
+
*/
|
|
28
|
+
type Any$6 = any;
|
|
29
|
+
declare class ZPP_Vec2 {
|
|
30
|
+
static zpp_pool: ZPP_Vec2 | null;
|
|
31
|
+
static __name__: string[];
|
|
32
|
+
static _nape: Any$6;
|
|
33
|
+
static _zpp: Any$6;
|
|
34
|
+
static _wrapFn: ((zpp: ZPP_Vec2) => Any$6) | null;
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
next: ZPP_Vec2 | null;
|
|
38
|
+
length: number;
|
|
39
|
+
modified: boolean;
|
|
40
|
+
pushmod: boolean;
|
|
41
|
+
_inuse: boolean;
|
|
42
|
+
weak: boolean;
|
|
43
|
+
outer: Any$6;
|
|
44
|
+
_immutable: boolean;
|
|
45
|
+
_isimmutable: (() => void) | null;
|
|
46
|
+
_validate: (() => void) | null;
|
|
47
|
+
_invalidate: ((self: ZPP_Vec2) => void) | null;
|
|
48
|
+
__class__: Any$6;
|
|
49
|
+
/** Static factory with optional pooling and immutability. */
|
|
50
|
+
static get(x: number, y: number, immutable?: boolean): ZPP_Vec2;
|
|
51
|
+
validate(): void;
|
|
52
|
+
invalidate(): void;
|
|
53
|
+
immutable(): void;
|
|
54
|
+
wrapper(): Any$6;
|
|
55
|
+
free(): void;
|
|
56
|
+
alloc(): void;
|
|
57
|
+
elem(): ZPP_Vec2;
|
|
58
|
+
begin(): ZPP_Vec2 | null;
|
|
59
|
+
setbegin(i: ZPP_Vec2 | null): void;
|
|
60
|
+
add(o: ZPP_Vec2): ZPP_Vec2;
|
|
61
|
+
inlined_add(o: ZPP_Vec2): ZPP_Vec2;
|
|
62
|
+
addAll(x: ZPP_Vec2): void;
|
|
63
|
+
insert(cur: ZPP_Vec2 | null, o: ZPP_Vec2): ZPP_Vec2;
|
|
64
|
+
inlined_insert(cur: ZPP_Vec2 | null, o: ZPP_Vec2): ZPP_Vec2;
|
|
65
|
+
pop(): void;
|
|
66
|
+
inlined_pop(): void;
|
|
67
|
+
pop_unsafe(): ZPP_Vec2;
|
|
68
|
+
inlined_pop_unsafe(): ZPP_Vec2;
|
|
69
|
+
remove(obj: ZPP_Vec2): void;
|
|
70
|
+
try_remove(obj: ZPP_Vec2): boolean;
|
|
71
|
+
inlined_remove(obj: ZPP_Vec2): void;
|
|
72
|
+
inlined_try_remove(obj: ZPP_Vec2): boolean;
|
|
73
|
+
erase(pre: ZPP_Vec2 | null): ZPP_Vec2 | null;
|
|
74
|
+
inlined_erase(pre: ZPP_Vec2 | null): ZPP_Vec2 | null;
|
|
75
|
+
splice(pre: ZPP_Vec2, n: number): ZPP_Vec2 | null;
|
|
76
|
+
clear(): void;
|
|
77
|
+
inlined_clear(): void;
|
|
78
|
+
reverse(): void;
|
|
79
|
+
empty(): boolean;
|
|
80
|
+
size(): number;
|
|
81
|
+
has(obj: ZPP_Vec2): boolean;
|
|
82
|
+
inlined_has(obj: ZPP_Vec2): boolean;
|
|
83
|
+
front(): ZPP_Vec2 | null;
|
|
84
|
+
back(): ZPP_Vec2 | null;
|
|
85
|
+
iterator_at(ind: number): ZPP_Vec2 | null;
|
|
86
|
+
at(ind: number): ZPP_Vec2 | null;
|
|
87
|
+
copy(): ZPP_Vec2;
|
|
88
|
+
toString(): string;
|
|
89
|
+
}
|
|
90
|
+
|
|
18
91
|
/**
|
|
19
92
|
* 2D vector used for positions, velocities, forces, and other 2D quantities.
|
|
20
93
|
*
|
|
21
|
-
*
|
|
94
|
+
* Supports object pooling via `Vec2.get()` / `dispose()`, weak references
|
|
95
|
+
* that auto-dispose after a single use, and immutability guards.
|
|
96
|
+
*
|
|
97
|
+
* Converted from nape-compiled.js lines 23448–27180.
|
|
22
98
|
*/
|
|
23
99
|
declare class Vec2 {
|
|
24
|
-
|
|
25
|
-
|
|
100
|
+
static __name__: string[];
|
|
101
|
+
/** @internal The internal ZPP_Vec2 this wrapper owns. */
|
|
102
|
+
zpp_inner: ZPP_Vec2;
|
|
103
|
+
/** @internal Public Vec2 pool link. */
|
|
104
|
+
zpp_pool: Vec2 | null;
|
|
105
|
+
/** @internal Whether this Vec2 has been disposed. */
|
|
106
|
+
zpp_disp: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Backward-compatible accessor — returns `this` so that compiled engine
|
|
109
|
+
* code that receives `vec._inner` can still access `zpp_inner`.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
get _inner(): NapeInner;
|
|
26
113
|
constructor(x?: number, y?: number);
|
|
27
|
-
/** @internal
|
|
28
|
-
|
|
114
|
+
/** @internal Check that this Vec2 has not been disposed. */
|
|
115
|
+
private _checkDisposed;
|
|
116
|
+
/** @internal Check immutability. */
|
|
117
|
+
private _checkImmutable;
|
|
118
|
+
/** @internal Validate (lazy evaluation callback). */
|
|
119
|
+
private _validate;
|
|
120
|
+
/** @internal Invalidate (notify dependents). */
|
|
121
|
+
private _invalidate;
|
|
122
|
+
/** @internal Dispose a weak Vec2 argument after use. */
|
|
123
|
+
private static _disposeWeak;
|
|
124
|
+
/**
|
|
125
|
+
* @internal Set x and y on zpp_inner with validation/invalidation.
|
|
126
|
+
* Only invalidates if values actually changed.
|
|
127
|
+
*/
|
|
128
|
+
private _setXY;
|
|
129
|
+
/** @internal Get a Vec2 from the public pool or create a new one. */
|
|
130
|
+
private static _poolGet;
|
|
131
|
+
/** @internal Wrap a ZPP_Vec2 (or legacy compiled Vec2) with caching. */
|
|
132
|
+
static _wrap(inner: any): Vec2;
|
|
133
|
+
/** Obtain a Vec2 from the object pool (or create a new one). */
|
|
134
|
+
static get(x?: number, y?: number, weak?: boolean): Vec2;
|
|
135
|
+
/** Obtain a weak Vec2 that auto-disposes after a single use. */
|
|
136
|
+
static weak(x?: number, y?: number): Vec2;
|
|
137
|
+
/** Create a Vec2 from polar coordinates. */
|
|
138
|
+
static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
|
|
139
|
+
/** Squared distance between two Vec2s. */
|
|
140
|
+
static dsq(a: Vec2, b: Vec2): number;
|
|
141
|
+
/** Euclidean distance between two Vec2s. */
|
|
142
|
+
static distance(a: Vec2, b: Vec2): number;
|
|
29
143
|
get x(): number;
|
|
30
144
|
set x(value: number);
|
|
31
145
|
get y(): number;
|
|
32
146
|
set y(value: number);
|
|
33
|
-
/** Magnitude of the vector.
|
|
147
|
+
/** Magnitude of the vector. */
|
|
34
148
|
get length(): number;
|
|
149
|
+
/** Setting length scales the vector to the given magnitude. */
|
|
35
150
|
set length(value: number);
|
|
36
151
|
/** Angle of the vector in radians (measured from the +x axis). */
|
|
37
152
|
get angle(): number;
|
|
153
|
+
/** Setting angle preserves magnitude but rotates to the given angle. */
|
|
38
154
|
set angle(value: number);
|
|
39
155
|
/** Squared length — avoids a square root when only comparison is needed. */
|
|
40
156
|
lsq(): number;
|
|
41
|
-
/** Copy values from another vector into this one (in-place). */
|
|
42
|
-
set(
|
|
43
|
-
/** Set both components at once (in-place). */
|
|
157
|
+
/** Copy values from another vector into this one (in-place). Returns this. */
|
|
158
|
+
set(vector: Vec2): this;
|
|
159
|
+
/** Set both components at once (in-place). Returns this. */
|
|
44
160
|
setxy(x: number, y: number): this;
|
|
45
161
|
/** Return a new copy of this vector. */
|
|
46
162
|
copy(weak?: boolean): Vec2;
|
|
47
|
-
/** Rotate this vector by the given angle in radians (in-place). */
|
|
163
|
+
/** Rotate this vector by the given angle in radians (in-place). Returns this. */
|
|
48
164
|
rotate(angle: number): this;
|
|
49
165
|
/** Reflect this vector about the given axis vector (returns new Vec2). */
|
|
50
|
-
reflect(
|
|
51
|
-
/** Normalize this vector to unit length (in-place). Returns
|
|
52
|
-
normalise():
|
|
166
|
+
reflect(vec: Vec2, weak?: boolean): Vec2;
|
|
167
|
+
/** Normalize this vector to unit length (in-place). Returns this. */
|
|
168
|
+
normalise(): this;
|
|
53
169
|
/** Return a new unit-length vector with the same direction. */
|
|
54
170
|
unit(weak?: boolean): Vec2;
|
|
55
171
|
/** Return a new vector = this + other. */
|
|
56
|
-
add(
|
|
172
|
+
add(vector: Vec2, weak?: boolean): Vec2;
|
|
57
173
|
/** Return a new vector = this + other * scalar. */
|
|
58
|
-
addMul(
|
|
59
|
-
/** Return a new vector = this
|
|
60
|
-
sub(
|
|
174
|
+
addMul(vector: Vec2, scalar: number, weak?: boolean): Vec2;
|
|
175
|
+
/** Return a new vector = this - other. */
|
|
176
|
+
sub(vector: Vec2, weak?: boolean): Vec2;
|
|
61
177
|
/** Return a new vector = this * scalar. */
|
|
62
178
|
mul(scalar: number, weak?: boolean): Vec2;
|
|
63
|
-
/** this += other (in-place). */
|
|
64
|
-
addeq(
|
|
65
|
-
/** this -= other (in-place). */
|
|
66
|
-
subeq(
|
|
67
|
-
/** this *= scalar (in-place). */
|
|
179
|
+
/** this += other (in-place). Returns this. */
|
|
180
|
+
addeq(vector: Vec2): this;
|
|
181
|
+
/** this -= other (in-place). Returns this. */
|
|
182
|
+
subeq(vector: Vec2): this;
|
|
183
|
+
/** this *= scalar (in-place). Returns this. */
|
|
68
184
|
muleq(scalar: number): this;
|
|
69
185
|
/** Dot product of this and other. */
|
|
70
|
-
dot(
|
|
71
|
-
/** 2D cross product (returns scalar: this.x*other.y
|
|
72
|
-
cross(
|
|
73
|
-
/** Return the perpendicular vector (rotated
|
|
186
|
+
dot(vector: Vec2): number;
|
|
187
|
+
/** 2D cross product (returns scalar: this.x*other.y - this.y*other.x). */
|
|
188
|
+
cross(vector: Vec2): number;
|
|
189
|
+
/** Return the perpendicular vector (rotated 90deg counter-clockwise). */
|
|
74
190
|
perp(weak?: boolean): Vec2;
|
|
75
191
|
/** Release this vector back to the object pool. */
|
|
76
192
|
dispose(): void;
|
|
77
193
|
toString(): string;
|
|
78
|
-
/** Obtain a Vec2 from the object pool (or create a new one). */
|
|
79
|
-
static get(x?: number, y?: number, weak?: boolean): Vec2;
|
|
80
|
-
/** Obtain a weak Vec2 that auto-disposes after a single use. */
|
|
81
|
-
static weak(x?: number, y?: number): Vec2;
|
|
82
|
-
/** Create a Vec2 from polar coordinates. */
|
|
83
|
-
static fromPolar(length: number, angle: number, weak?: boolean): Vec2;
|
|
84
194
|
}
|
|
85
195
|
/** @internal Opaque handle for any Haxe-compiled nape object. */
|
|
86
196
|
type NapeInner = any;
|
|
87
197
|
|
|
198
|
+
/**
|
|
199
|
+
* ZPP_Vec3 — Internal 3D vector for the nape physics engine.
|
|
200
|
+
*
|
|
201
|
+
* Simple x, y, z data container with optional validation callback.
|
|
202
|
+
* Used internally for constraint anchor points and similar 3-component values.
|
|
203
|
+
*
|
|
204
|
+
* Converted from nape-compiled.js lines 83412–83434.
|
|
205
|
+
*/
|
|
206
|
+
type Any$5 = any;
|
|
207
|
+
declare class ZPP_Vec3 {
|
|
208
|
+
static __name__: string[];
|
|
209
|
+
static _zpp: Any$5;
|
|
210
|
+
static _wrapFn: ((zpp: ZPP_Vec3) => Any$5) | null;
|
|
211
|
+
outer: Any$5;
|
|
212
|
+
x: number;
|
|
213
|
+
y: number;
|
|
214
|
+
z: number;
|
|
215
|
+
immutable: boolean;
|
|
216
|
+
_validate: (() => void) | null;
|
|
217
|
+
__class__: Any$5;
|
|
218
|
+
validate(): void;
|
|
219
|
+
wrapper(): Any$5;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 3D vector used for constraint impulses and other 3-component values.
|
|
224
|
+
*
|
|
225
|
+
* Supports object pooling via `Vec3.get()` / `dispose()`.
|
|
226
|
+
*
|
|
227
|
+
* Converted from nape-compiled.js lines 24120–25040.
|
|
228
|
+
*/
|
|
229
|
+
declare class Vec3 {
|
|
230
|
+
static __name__: string[];
|
|
231
|
+
/** @internal The internal ZPP_Vec3 this wrapper owns. */
|
|
232
|
+
zpp_inner: ZPP_Vec3;
|
|
233
|
+
/** @internal Public Vec3 pool link. */
|
|
234
|
+
zpp_pool: Vec3 | null;
|
|
235
|
+
/** @internal Whether this Vec3 has been disposed. */
|
|
236
|
+
zpp_disp: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Backward-compatible accessor — returns `this` so that compiled engine
|
|
239
|
+
* code that receives `v3._inner` can still access `zpp_inner`.
|
|
240
|
+
* @internal
|
|
241
|
+
*/
|
|
242
|
+
get _inner(): NapeInner;
|
|
243
|
+
constructor(x?: number, y?: number, z?: number);
|
|
244
|
+
/** @internal Check that this Vec3 has not been disposed. */
|
|
245
|
+
private _checkDisposed;
|
|
246
|
+
/** @internal Check immutability. */
|
|
247
|
+
private _checkImmutable;
|
|
248
|
+
/** @internal Wrap a ZPP_Vec3 (or legacy compiled Vec3) with caching. */
|
|
249
|
+
static _wrap(inner: any): Vec3;
|
|
250
|
+
/** Obtain a Vec3 from the object pool (or create a new one). */
|
|
251
|
+
static get(x?: number, y?: number, z?: number): Vec3;
|
|
252
|
+
get x(): number;
|
|
253
|
+
set x(value: number);
|
|
254
|
+
get y(): number;
|
|
255
|
+
set y(value: number);
|
|
256
|
+
get z(): number;
|
|
257
|
+
set z(value: number);
|
|
258
|
+
/** Magnitude of the 3D vector. */
|
|
259
|
+
get length(): number;
|
|
260
|
+
/** Setting length scales the vector to the given magnitude. */
|
|
261
|
+
set length(value: number);
|
|
262
|
+
/** Squared length — avoids a square root when only comparison is needed. */
|
|
263
|
+
lsq(): number;
|
|
264
|
+
/** Copy values from another Vec3 into this one (in-place). Returns this. */
|
|
265
|
+
set(vector: Vec3): this;
|
|
266
|
+
/** Set all three components at once (in-place). Returns this. */
|
|
267
|
+
setxyz(x: number, y: number, z: number): this;
|
|
268
|
+
/** Return the x,y components as a Vec2. */
|
|
269
|
+
xy(weak?: boolean): Vec2;
|
|
270
|
+
/** Release this Vec3 back to the object pool. */
|
|
271
|
+
dispose(): void;
|
|
272
|
+
toString(): string;
|
|
273
|
+
}
|
|
274
|
+
|
|
88
275
|
/**
|
|
89
276
|
* ZPP_AABB — Internal axis-aligned bounding box for the nape physics engine.
|
|
90
277
|
*
|
|
@@ -1166,4 +1353,4 @@ declare class PulleyJoint extends Constraint {
|
|
|
1166
1353
|
set ratio(value: number);
|
|
1167
1354
|
}
|
|
1168
1355
|
|
|
1169
|
-
export { AABB, AngleJoint, Body, BodyListener, BodyType, CbEvent, CbType, Circle, Constraint, ConstraintListener, DistanceJoint, FluidProperties, InteractionFilter, InteractionGroup, InteractionListener, InteractionType, LineJoint, Listener, Material, MotorJoint, NapeList, OptionType, PivotJoint, Polygon, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, Vec2, WeldJoint, getNape };
|
|
1356
|
+
export { AABB, AngleJoint, Body, BodyListener, BodyType, CbEvent, CbType, Circle, Constraint, ConstraintListener, DistanceJoint, FluidProperties, InteractionFilter, InteractionGroup, InteractionListener, InteractionType, LineJoint, Listener, Material, MotorJoint, NapeList, OptionType, PivotJoint, Polygon, PreFlag, PreListener, PulleyJoint, Shape, ShapeType, Space, Vec2, Vec3, WeldJoint, getNape };
|