@daneren2005/shared-memory-physics 1.9.2 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.js +238 -222
- package/dist/index.js.map +1 -1
- package/dist/systems/physics-update.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -136,7 +136,7 @@ var k = class extends t {
|
|
|
136
136
|
}, n = e.angle;
|
|
137
137
|
return n !== 0 && (t.angle = n), t;
|
|
138
138
|
}
|
|
139
|
-
}, j = 0, ee = 1, te = 2,
|
|
139
|
+
}, j = 0, ee = 1, te = 2, M = 3, ne = class extends t {
|
|
140
140
|
get velocityX() {
|
|
141
141
|
return this.block[0];
|
|
142
142
|
}
|
|
@@ -153,9 +153,9 @@ var k = class extends t {
|
|
|
153
153
|
return this.block[2];
|
|
154
154
|
}
|
|
155
155
|
set damping(e) {
|
|
156
|
-
|
|
156
|
+
P(e), this.block[2] = e;
|
|
157
157
|
}
|
|
158
|
-
},
|
|
158
|
+
}, N = {
|
|
159
159
|
type: Float32Array,
|
|
160
160
|
size: 3,
|
|
161
161
|
loadProperties: [
|
|
@@ -165,14 +165,14 @@ var k = class extends t {
|
|
|
165
165
|
],
|
|
166
166
|
toBlock(e) {
|
|
167
167
|
let t = e.damping ?? 0;
|
|
168
|
-
return
|
|
168
|
+
return P(t), [
|
|
169
169
|
e.velocityX ?? 0,
|
|
170
170
|
e.velocityY ?? 0,
|
|
171
171
|
t
|
|
172
172
|
];
|
|
173
173
|
},
|
|
174
174
|
attach(e, t, n) {
|
|
175
|
-
return new
|
|
175
|
+
return new ne(t.getBlock(n), n);
|
|
176
176
|
},
|
|
177
177
|
save(e) {
|
|
178
178
|
return {
|
|
@@ -182,30 +182,30 @@ var k = class extends t {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
function
|
|
185
|
+
function P(e) {
|
|
186
186
|
if (!Number.isFinite(e) || e < 0) throw Error("Damping must be a finite number of at least zero");
|
|
187
187
|
}
|
|
188
188
|
// src/components/dynamics-component-constants.ts
|
|
189
|
-
var
|
|
189
|
+
var re = 0, ie = 1, ae = 2, oe = 3, se = class extends t {
|
|
190
190
|
get accelerationX() {
|
|
191
191
|
return this.block[0];
|
|
192
192
|
}
|
|
193
193
|
set accelerationX(e) {
|
|
194
|
-
|
|
194
|
+
ue(e, "Acceleration"), this.block[0] = e;
|
|
195
195
|
}
|
|
196
196
|
get accelerationY() {
|
|
197
197
|
return this.block[1];
|
|
198
198
|
}
|
|
199
199
|
set accelerationY(e) {
|
|
200
|
-
|
|
200
|
+
ue(e, "Acceleration"), this.block[1] = e;
|
|
201
201
|
}
|
|
202
202
|
get mass() {
|
|
203
203
|
return 1 / this.block[2];
|
|
204
204
|
}
|
|
205
205
|
set mass(e) {
|
|
206
|
-
|
|
206
|
+
le(e), this.block[2] = 1 / e;
|
|
207
207
|
}
|
|
208
|
-
},
|
|
208
|
+
}, ce = {
|
|
209
209
|
type: Float32Array,
|
|
210
210
|
size: 3,
|
|
211
211
|
loadProperties: [
|
|
@@ -215,14 +215,14 @@ var ie = 0, ae = 1, oe = 2, se = 3, ce = class extends t {
|
|
|
215
215
|
],
|
|
216
216
|
toBlock(e) {
|
|
217
217
|
let t = e.accelerationX ?? 0, n = e.accelerationY ?? 0, r = e.mass ?? 1;
|
|
218
|
-
return
|
|
218
|
+
return ue(t, "Acceleration"), ue(n, "Acceleration"), le(r), [
|
|
219
219
|
t,
|
|
220
220
|
n,
|
|
221
221
|
1 / r
|
|
222
222
|
];
|
|
223
223
|
},
|
|
224
224
|
attach(e, t, n) {
|
|
225
|
-
return new
|
|
225
|
+
return new se(t.getBlock(n), n);
|
|
226
226
|
},
|
|
227
227
|
save(e) {
|
|
228
228
|
return {
|
|
@@ -232,41 +232,41 @@ var ie = 0, ae = 1, oe = 2, se = 3, ce = class extends t {
|
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
|
-
function
|
|
235
|
+
function le(e) {
|
|
236
236
|
if (!Number.isFinite(e) || e <= 0) throw Error("Mass must be a finite number greater than zero");
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function ue(e, t) {
|
|
239
239
|
if (!Number.isFinite(e)) throw Error(`${t} must be a finite number`);
|
|
240
240
|
}
|
|
241
241
|
// src/components/body-component-constants.ts
|
|
242
|
-
var
|
|
242
|
+
var de = 1, fe = 2, pe = 3, me = 4, he = 1, ge = 4294967295, _e = 0, ve = 1, ye = 2, be = 3, xe = 7, Se = 8, Ce = 16, we = 32, Te = 64, Ee = [
|
|
243
243
|
1,
|
|
244
244
|
2,
|
|
245
245
|
3,
|
|
246
246
|
4
|
|
247
247
|
];
|
|
248
|
-
function
|
|
248
|
+
function De(e, t, n, r) {
|
|
249
249
|
return (t & n) !== 0 && (r & e) !== 0;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function F(e) {
|
|
252
252
|
return e[0] & 7;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function I(e) {
|
|
255
255
|
return !!(e[0] & 8);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Oe(e) {
|
|
258
258
|
return !!(e[0] & 16);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function ke(e) {
|
|
261
261
|
return !!(e[0] & 64);
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function Ae(e) {
|
|
264
264
|
return !!(e[0] & 32);
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function je(e) {
|
|
267
267
|
e[0] |= 32;
|
|
268
268
|
}
|
|
269
|
-
var
|
|
269
|
+
var Me = class extends t {
|
|
270
270
|
get shape() {
|
|
271
271
|
return this.block[0] & 7;
|
|
272
272
|
}
|
|
@@ -303,7 +303,7 @@ var Ne = class extends t {
|
|
|
303
303
|
set blocksPath(e) {
|
|
304
304
|
this.block[0] = e ? this.block[0] | 64 : this.block[0] & -65;
|
|
305
305
|
}
|
|
306
|
-
},
|
|
306
|
+
}, Ne = {
|
|
307
307
|
type: Uint32Array,
|
|
308
308
|
size: 3,
|
|
309
309
|
loadProperties: [
|
|
@@ -320,35 +320,35 @@ var Ne = class extends t {
|
|
|
320
320
|
],
|
|
321
321
|
toBlock(e) {
|
|
322
322
|
return [
|
|
323
|
-
|
|
323
|
+
Pe(e),
|
|
324
324
|
e.collideCategory ?? 1,
|
|
325
325
|
e.collideMask ?? 4294967295
|
|
326
326
|
];
|
|
327
327
|
},
|
|
328
328
|
attach(e, t, n) {
|
|
329
|
-
return new
|
|
329
|
+
return new Me(t.getBlock(n), n);
|
|
330
330
|
}
|
|
331
331
|
};
|
|
332
|
-
function
|
|
333
|
-
let t =
|
|
332
|
+
function Pe(e) {
|
|
333
|
+
let t = Fe(e);
|
|
334
334
|
return e.sensor && (t |= 8), e.continuousCollisionDetection && (t |= 16), e.blocksPath && (t |= 64), t;
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function Fe(e) {
|
|
337
337
|
let t = e.shape;
|
|
338
338
|
if (t === void 0) return e.vertices === void 0 ? e.radius === void 0 ? 1 : 2 : 4;
|
|
339
|
-
if (!
|
|
339
|
+
if (!Ee.includes(t)) throw Error(`Unknown body shape: ${t}`);
|
|
340
340
|
if (t === 4 && e.vertices === void 0) throw Error("A polygon body requires vertices");
|
|
341
341
|
return t;
|
|
342
342
|
}
|
|
343
343
|
// src/components/bounciness-component-constants.ts
|
|
344
|
-
var
|
|
344
|
+
var Ie = 0, Le = 1, Re = class extends t {
|
|
345
345
|
get bounciness() {
|
|
346
346
|
return this.block[0];
|
|
347
347
|
}
|
|
348
348
|
set bounciness(e) {
|
|
349
349
|
this.block[0] = e;
|
|
350
350
|
}
|
|
351
|
-
},
|
|
351
|
+
}, ze = {
|
|
352
352
|
type: Float32Array,
|
|
353
353
|
size: 1,
|
|
354
354
|
loadProperties: ["bounciness"],
|
|
@@ -356,9 +356,9 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
356
356
|
return [e.bounciness ?? 0];
|
|
357
357
|
},
|
|
358
358
|
attach(e, t, n) {
|
|
359
|
-
return new
|
|
359
|
+
return new Re(t.getBlock(n), n);
|
|
360
360
|
}
|
|
361
|
-
},
|
|
361
|
+
}, Be = 0, Ve = 1, He = 2, Ue = 3, We = 4, Ge = 5, Ke = 6, qe = 7, Je = 8, Ye = 9, Xe = 10, Ze = 11, Qe = 12, $e = 13, et = 14, tt = 15, nt = 16, rt = 17, it = class extends t {
|
|
362
362
|
get x() {
|
|
363
363
|
return this.block[0];
|
|
364
364
|
}
|
|
@@ -437,7 +437,7 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
437
437
|
set remainingDuration(e) {
|
|
438
438
|
this.block[7] = e;
|
|
439
439
|
}
|
|
440
|
-
},
|
|
440
|
+
}, at = {
|
|
441
441
|
type: Float32Array,
|
|
442
442
|
size: 17,
|
|
443
443
|
loadProperties: ["interpolate"],
|
|
@@ -464,13 +464,13 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
464
464
|
];
|
|
465
465
|
},
|
|
466
466
|
attach(e, t, n) {
|
|
467
|
-
return new
|
|
467
|
+
return new it(t.getBlock(n), n);
|
|
468
468
|
}
|
|
469
|
-
},
|
|
469
|
+
}, ot = 0, st = 1, ct = 2, lt = 3, ut = 4, dt = 5, ft = 6, pt = 7, mt = 8, ht = 32, gt = 72, L = {
|
|
470
470
|
Found: 1,
|
|
471
471
|
Incomplete: 2,
|
|
472
472
|
Unreachable: 3
|
|
473
|
-
},
|
|
473
|
+
}, _t = class extends t {
|
|
474
474
|
get active() {
|
|
475
475
|
return this.block[5] !== 0;
|
|
476
476
|
}
|
|
@@ -481,7 +481,7 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
481
481
|
return i(this.block, 7);
|
|
482
482
|
}
|
|
483
483
|
get pending() {
|
|
484
|
-
return
|
|
484
|
+
return wt(this.block);
|
|
485
485
|
}
|
|
486
486
|
get outcome() {
|
|
487
487
|
return this.block[2];
|
|
@@ -490,57 +490,57 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
490
490
|
return this.block[3];
|
|
491
491
|
}
|
|
492
492
|
get waypoints() {
|
|
493
|
-
return Array.from({ length: this.block[4] }, (e, t) =>
|
|
493
|
+
return Array.from({ length: this.block[4] }, (e, t) => Dt(this.block, t));
|
|
494
494
|
}
|
|
495
495
|
navigateTo(e, t) {
|
|
496
|
-
|
|
496
|
+
yt(this.block, e, t);
|
|
497
497
|
}
|
|
498
498
|
stop() {
|
|
499
|
-
|
|
499
|
+
xt(this.block);
|
|
500
500
|
}
|
|
501
|
-
},
|
|
501
|
+
}, vt = {
|
|
502
502
|
type: Int32Array,
|
|
503
503
|
size: 72,
|
|
504
504
|
loadProperties: ["navigate"],
|
|
505
505
|
toBlock: () => Array.from({ length: 72 }, () => 0),
|
|
506
506
|
attach(e, t, n) {
|
|
507
|
-
return new
|
|
507
|
+
return new _t(t.getBlock(n), n);
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
|
-
function
|
|
511
|
-
|
|
510
|
+
function yt(e, t, n) {
|
|
511
|
+
bt(e, t, n), e[5] = 1, Ct(e);
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function bt(e, t, n) {
|
|
514
514
|
a(e, 6, t), a(e, 7, n);
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function xt(e) {
|
|
517
517
|
e[5] = 0;
|
|
518
518
|
}
|
|
519
|
-
function
|
|
519
|
+
function St(e) {
|
|
520
520
|
return e[5] !== 0;
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function Ct(e) {
|
|
523
523
|
Atomics.add(e, 0, 1);
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function wt(e) {
|
|
526
526
|
return Atomics.load(e, 0) !== Atomics.load(e, 1);
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
return !
|
|
528
|
+
function Tt(e) {
|
|
529
|
+
return !wt(e) && e[2] === L.Unreachable;
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function Et(e) {
|
|
532
532
|
return {
|
|
533
533
|
x: i(e, 6),
|
|
534
534
|
y: i(e, 7)
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function Dt(e, t) {
|
|
538
538
|
return {
|
|
539
|
-
x:
|
|
539
|
+
x: Ot(e, t),
|
|
540
540
|
y: kt(e, t)
|
|
541
541
|
};
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function Ot(e, t) {
|
|
544
544
|
return i(e, 8 + t * 2);
|
|
545
545
|
}
|
|
546
546
|
function kt(e, t) {
|
|
@@ -549,18 +549,18 @@ function kt(e, t) {
|
|
|
549
549
|
function At(e, t, n) {
|
|
550
550
|
let r = n.length > 32, i = r ? 32 : n.length;
|
|
551
551
|
for (let t = 0; t < i; t++) a(e, 8 + t * 2, n[t].x), a(e, 8 + t * 2 + 1, n[t].y);
|
|
552
|
-
e[4] = i, e[3] = 0, e[2] = r ?
|
|
552
|
+
e[4] = i, e[3] = 0, e[2] = r ? L.Incomplete : t;
|
|
553
553
|
}
|
|
554
554
|
// src/components/registry.ts
|
|
555
555
|
var jt = {
|
|
556
556
|
transform: A,
|
|
557
|
-
velocity:
|
|
558
|
-
body:
|
|
557
|
+
velocity: N,
|
|
558
|
+
body: Ne,
|
|
559
559
|
polygon: T,
|
|
560
|
-
bounciness:
|
|
561
|
-
dynamics:
|
|
562
|
-
interpolation:
|
|
563
|
-
}, Mt = { navigation:
|
|
560
|
+
bounciness: ze,
|
|
561
|
+
dynamics: ce,
|
|
562
|
+
interpolation: at
|
|
563
|
+
}, Mt = { navigation: vt }, R = {
|
|
564
564
|
x: 0,
|
|
565
565
|
y: 0
|
|
566
566
|
}, z = {
|
|
@@ -691,7 +691,7 @@ function q(e) {
|
|
|
691
691
|
}
|
|
692
692
|
// src/systems/spatial-bounds.ts
|
|
693
693
|
function J(e) {
|
|
694
|
-
let t = e.transform, n = e.body ?
|
|
694
|
+
let t = e.transform, n = e.body ? F(e.body) : 1, r = t[2], i = t[3], a = t[4], o = H(n, r, i, a), s = U(n, r, i, a), c = t[0], l = t[1];
|
|
695
695
|
return {
|
|
696
696
|
minX: c - o,
|
|
697
697
|
minY: l - s,
|
|
@@ -839,9 +839,9 @@ function sn(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
|
|
|
839
839
|
return ln(g, _, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) && ln(-_, g, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h);
|
|
840
840
|
}
|
|
841
841
|
function cn(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E) {
|
|
842
|
-
let D = e === 3 ? B(r, i) : 0, O = V(r, i, a), k = Math.cos(O) * D, A = Math.sin(O) * D, j = t - k, ee = n - A, te = t + k,
|
|
843
|
-
for (let e = 0; e <
|
|
844
|
-
let t = dn(o, e, s, l, u,
|
|
842
|
+
let D = e === 3 ? B(r, i) : 0, O = V(r, i, a), k = Math.cos(O) * D, A = Math.sin(O) * D, j = t - k, ee = n - A, te = t + k, M = n + A, ne = o[0], N = Math.cos(d), P = Math.sin(d);
|
|
843
|
+
for (let e = 0; e < ne; e++) {
|
|
844
|
+
let t = dn(o, e, s, l, u, N, P), n = fn(o, e, c, l, u, N, P), r = pn(j, ee, te, M, t, n), i = j + (te - j) * r, a = ee + (M - ee) * r;
|
|
845
845
|
if (!ln(t - i, n - a, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E)) return !1;
|
|
846
846
|
}
|
|
847
847
|
return !0;
|
|
@@ -945,18 +945,18 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
945
945
|
if (!o || !s) continue;
|
|
946
946
|
let c = s[1];
|
|
947
947
|
if (c === 0) continue;
|
|
948
|
-
let l =
|
|
948
|
+
let l = F(s), u = o[2], d = o[3];
|
|
949
949
|
if (Pt(l, u, d)) continue;
|
|
950
950
|
let f = o[4], p = H(l, u, d, f), m = U(l, u, d, f);
|
|
951
951
|
e.bounciness && (this.hasBounciness = !0);
|
|
952
|
-
let h = e.velocity, g = e.dynamics, _ = gn(a, n.entityId), v = i ? _n(i, n.entityId) : -1, y = g?.[2] ?? 1, b = v < 0 ? _?.forceX ?? 0 : i[v + 1], x = v < 0 ? _?.forceY ?? 0 : i[v + 2], S = v < 0 ? _?.impulseX ?? 0 : i[v + 3], C = v < 0 ? _?.impulseY ?? 0 : i[v + 4], w = v < 0 ? 0 : i[v + 5], T = v < 0 ? _?.velocityX : w & 1 ? i[v + 6] : void 0, E = v < 0 ? _?.velocityY : w & 2 ? i[v + 7] : void 0, D = h?.[0] ?? 0, O = h?.[1] ?? 0, k = D + (g?.[0] ?? 0) * t + b * y * t + S * y, A = O + (g?.[1] ?? 0) * t + x * y * t + C * y, j = T ?? k, ee = E ?? A, te = Math.max(Math.abs(D), Math.abs(j)) * t,
|
|
953
|
-
|
|
952
|
+
let h = e.velocity, g = e.dynamics, _ = gn(a, n.entityId), v = i ? _n(i, n.entityId) : -1, y = g?.[2] ?? 1, b = v < 0 ? _?.forceX ?? 0 : i[v + 1], x = v < 0 ? _?.forceY ?? 0 : i[v + 2], S = v < 0 ? _?.impulseX ?? 0 : i[v + 3], C = v < 0 ? _?.impulseY ?? 0 : i[v + 4], w = v < 0 ? 0 : i[v + 5], T = v < 0 ? _?.velocityX : w & 1 ? i[v + 6] : void 0, E = v < 0 ? _?.velocityY : w & 2 ? i[v + 7] : void 0, D = h?.[0] ?? 0, O = h?.[1] ?? 0, k = D + (g?.[0] ?? 0) * t + b * y * t + S * y, A = O + (g?.[1] ?? 0) * t + x * y * t + C * y, j = T ?? k, ee = E ?? A, te = Math.max(Math.abs(D), Math.abs(j)) * t, M = Math.max(Math.abs(O), Math.abs(ee)) * t, ne = o[0], N = o[1], P = r.get(c);
|
|
953
|
+
P || (P = {
|
|
954
954
|
entries: [],
|
|
955
955
|
bounds: []
|
|
956
|
-
}, r.set(c,
|
|
956
|
+
}, r.set(c, P)), P.entries.push({
|
|
957
957
|
entityId: n.entityId,
|
|
958
958
|
components: e
|
|
959
|
-
}),
|
|
959
|
+
}), P.bounds.push(ne - p - te, N - m - M, ne + p + te, N + m + M);
|
|
960
960
|
}
|
|
961
961
|
for (let [e, { entries: t, bounds: n }] of r) {
|
|
962
962
|
let r = new s(t.length);
|
|
@@ -1082,7 +1082,7 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
1082
1082
|
if (e.sensor) return [];
|
|
1083
1083
|
let s = r + t, c = i + n, l = [];
|
|
1084
1084
|
return this.forEachCandidate(e, s - a, c - o, s + a, c + o, (t) => {
|
|
1085
|
-
Z(e, s, c, t) && (
|
|
1085
|
+
Z(e, s, c, t) && (I(t.components.body) || Z(e, r, i, t) || l.push(t));
|
|
1086
1086
|
}), l;
|
|
1087
1087
|
}
|
|
1088
1088
|
refine(e, t, n, r, i) {
|
|
@@ -1102,7 +1102,7 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
1102
1102
|
if (e.sensor) return [];
|
|
1103
1103
|
let { x: r, y: i, halfWidth: a, halfHeight: o } = e, s = r + t, c = i + n, l = [];
|
|
1104
1104
|
return this.forEachCandidate(e, Math.min(r, s) - a, Math.min(i, c) - o, Math.max(r, s) + a, Math.max(i, c) + o, (a) => {
|
|
1105
|
-
|
|
1105
|
+
I(a.components.body) || Z(e, r, i, a) || En(e, r, i, t, n, a) && l.push(a);
|
|
1106
1106
|
}), l;
|
|
1107
1107
|
}
|
|
1108
1108
|
sweepContinuous(e, t, n, r) {
|
|
@@ -1147,12 +1147,12 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
1147
1147
|
forEachCandidate(e, t, r, i, a, o) {
|
|
1148
1148
|
for (let s of this.buckets) if ((e.mask & s.category) !== 0) for (let c of s.index.search(t, r, i, a)) {
|
|
1149
1149
|
let t = s.entries[c];
|
|
1150
|
-
t.entityId !== e.entityId && (t.components.body[2] & e.category) !== 0 && t.components.entity?.[n] !== 1 && (
|
|
1150
|
+
t.entityId !== e.entityId && (t.components.body[2] & e.category) !== 0 && t.components.entity?.[n] !== 1 && (Ae(t.components.body) || o(t));
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
1153
|
};
|
|
1154
1154
|
function Cn(e, t, n, r, i) {
|
|
1155
|
-
let a = r.components.transform, o =
|
|
1155
|
+
let a = r.components.transform, o = F(r.components.body), s = a[0], c = a[1], l = a[2], u = a[3], d = a[4];
|
|
1156
1156
|
return e.shape === 4 || o === 4 ? rn(e.shape, e.polygon, t, n, e.width, e.height, e.angle, o, r.components.polygon, s, c, l, u, d, i) : Lt(e.shape, t, n, e.width, e.height, e.angle, o, s, c, l, u, d, i);
|
|
1157
1157
|
}
|
|
1158
1158
|
function wn(e, t) {
|
|
@@ -1167,7 +1167,7 @@ function Tn(e) {
|
|
|
1167
1167
|
if (!t) return;
|
|
1168
1168
|
let n = t[2];
|
|
1169
1169
|
if (n === 0) return;
|
|
1170
|
-
let r = e.components.transform, i =
|
|
1170
|
+
let r = e.components.transform, i = F(t), a = r[2], o = r[3];
|
|
1171
1171
|
if (Pt(i, a, o)) return;
|
|
1172
1172
|
let s = r[4], c = e.components.polygon;
|
|
1173
1173
|
if (i !== 4 || c) return {
|
|
@@ -1183,12 +1183,12 @@ function Tn(e) {
|
|
|
1183
1183
|
halfHeight: U(i, a, o, s),
|
|
1184
1184
|
category: t[1],
|
|
1185
1185
|
mask: n,
|
|
1186
|
-
sensor:
|
|
1187
|
-
ccd:
|
|
1186
|
+
sensor: I(t),
|
|
1187
|
+
ccd: Oe(t)
|
|
1188
1188
|
};
|
|
1189
1189
|
}
|
|
1190
1190
|
function En(e, t, n, r, i, a) {
|
|
1191
|
-
let o = t + r, s = n + i, c = a.components.transform, l =
|
|
1191
|
+
let o = t + r, s = n + i, c = a.components.transform, l = F(a.components.body), u = c[0], d = c[1], f = c[2], p = c[3], m = c[4];
|
|
1192
1192
|
if (e.shape === 1 || e.shape === 4) {
|
|
1193
1193
|
let c = Math.cos(e.angle), h = Math.sin(e.angle), g = r * c + i * h, _ = -r * h + i * c;
|
|
1194
1194
|
return On(1, void 0, (t + o) / 2, (n + s) / 2, e.width + Math.abs(g), e.height + Math.abs(_), e.angle, l, a.components.polygon, u, d, f, p, m);
|
|
@@ -1201,7 +1201,7 @@ function Dn(e) {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
function Z(e, t, n, r) {
|
|
1203
1203
|
let i = r.components.transform;
|
|
1204
|
-
return On(e.shape, e.polygon, t, n, e.width, e.height, e.angle,
|
|
1204
|
+
return On(e.shape, e.polygon, t, n, e.width, e.height, e.angle, F(r.components.body), r.components.polygon, i[0], i[1], i[2], i[3], i[4]);
|
|
1205
1205
|
}
|
|
1206
1206
|
function On(e, t, n, r, i, a, o, s, c, l, u, d, f, p) {
|
|
1207
1207
|
return e !== 4 && s !== 4 ? Ft(e, n, r, i, a, o, s, l, u, d, f, p) : nn(e, t, n, r, i, a, o, s, c, l, u, d, f, p);
|
|
@@ -1215,7 +1215,7 @@ var kn = class {
|
|
|
1215
1215
|
for (let n of e) {
|
|
1216
1216
|
let e = n.components, r = e.transform;
|
|
1217
1217
|
if (!r) continue;
|
|
1218
|
-
let i = e.body, a = i ?
|
|
1218
|
+
let i = e.body, a = i ? F(i) : 1, o = r[2], s = r[3], c = r[4], l = r[0], u = r[1], d = H(a, o, s, c), f = U(a, o, s, c);
|
|
1219
1219
|
this.entries.push({
|
|
1220
1220
|
entityId: n.entityId,
|
|
1221
1221
|
components: e
|
|
@@ -1331,10 +1331,10 @@ function Hn(e, t, n) {
|
|
|
1331
1331
|
return a === 4 || o === 4 ? rn(a, e.components.polygon, r[0], r[1], r[2], r[3], r[4], o, t.components.polygon, i[0], i[1], i[2], i[3], i[4], n) : Lt(a, r[0], r[1], r[2], r[3], r[4], o, i[0], i[1], i[2], i[3], i[4], n);
|
|
1332
1332
|
}
|
|
1333
1333
|
function Un(e) {
|
|
1334
|
-
return e ?
|
|
1334
|
+
return e ? F(e) : 1;
|
|
1335
1335
|
}
|
|
1336
1336
|
function Wn(e) {
|
|
1337
|
-
return e !== void 0 &&
|
|
1337
|
+
return e !== void 0 && I(e);
|
|
1338
1338
|
}
|
|
1339
1339
|
// src/actions/combine-dynamics-commands.ts
|
|
1340
1340
|
function Gn(e, t) {
|
|
@@ -1401,15 +1401,19 @@ function Xn(e) {
|
|
|
1401
1401
|
var Zn = {
|
|
1402
1402
|
x: 0,
|
|
1403
1403
|
y: 0
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1404
|
+
}, Qn = [
|
|
1405
|
+
"transform",
|
|
1406
|
+
"velocity",
|
|
1407
|
+
"interpolation"
|
|
1408
|
+
];
|
|
1409
|
+
function $n(e = {}) {
|
|
1406
1410
|
let { onCollision: t, optional: r = [], group: i, stopVelocityOnContact: a = !1 } = e, o, s, c = /* @__PURE__ */ new Map(), l = Object.assign((e, r, c, l, u) => {
|
|
1407
1411
|
if (c.entity?.[n] === 1) return;
|
|
1408
|
-
if (c.body !== void 0 &&
|
|
1412
|
+
if (c.body !== void 0 && Ae(c.body)) {
|
|
1409
1413
|
u.entityDied(r);
|
|
1410
1414
|
return;
|
|
1411
1415
|
}
|
|
1412
|
-
let d = i ?
|
|
1416
|
+
let d = i ? tr(c, i) : 0;
|
|
1413
1417
|
if (i && e.skipGroup === d) return;
|
|
1414
1418
|
let f = {
|
|
1415
1419
|
entityId: r,
|
|
@@ -1417,28 +1421,33 @@ function Qn(e = {}) {
|
|
|
1417
1421
|
}, p = c.interpolation, m = e.elapsedTime / 1e3;
|
|
1418
1422
|
Fn(e, r, c.velocity, c.dynamics);
|
|
1419
1423
|
let h = c.velocity[0] * m, g = c.velocity[1] * m;
|
|
1420
|
-
|
|
1424
|
+
or(p, c.transform, e);
|
|
1421
1425
|
let _ = i ? s?.get(d) : o;
|
|
1422
1426
|
if (!_) {
|
|
1423
|
-
|
|
1427
|
+
cr(r, c.transform, h, g, u, e.reportMoves), Q(e, r, c), sr(p, e.tick);
|
|
1424
1428
|
return;
|
|
1425
1429
|
}
|
|
1426
1430
|
let v = c.bounciness !== void 0, y = _.resolveMove(f, h, g, !v);
|
|
1427
|
-
if (
|
|
1431
|
+
if (cr(r, c.transform, y.moveX, y.moveY, u, e.reportMoves), Q(e, r, c), sr(p, e.tick), _.hasBounciness || a || t) {
|
|
1428
1432
|
_.forEachOverlapping(f, (n) => {
|
|
1429
|
-
_.claimContact(r, n.entityId) &&
|
|
1433
|
+
_.claimContact(r, n.entityId) && nr(e, _, f, n, l, u, y.moveX, y.moveY, a, t);
|
|
1430
1434
|
}, y.moveX, y.moveY);
|
|
1431
|
-
for (let n of y.blocking) _.claimContact(r, n.entityId) &&
|
|
1435
|
+
for (let n of y.blocking) _.claimContact(r, n.entityId) && nr(e, _, f, n, l, u, y.moveX, y.moveY, a, t);
|
|
1432
1436
|
}
|
|
1433
1437
|
}, { physics: {
|
|
1434
1438
|
collision: !0,
|
|
1435
1439
|
dynamics: !0,
|
|
1436
1440
|
optional: r,
|
|
1437
|
-
group: i
|
|
1441
|
+
group: i,
|
|
1442
|
+
writes: t ? [
|
|
1443
|
+
...Qn,
|
|
1444
|
+
"body",
|
|
1445
|
+
"entity"
|
|
1446
|
+
] : [...Qn]
|
|
1438
1447
|
} });
|
|
1439
1448
|
return l.preRun = (e, t, n) => {
|
|
1440
|
-
|
|
1441
|
-
|
|
1449
|
+
er(e, c), e.dieAtImpact = (t, n) => {
|
|
1450
|
+
ir(e, i ? s?.get(tr(t.components, i)) : o, t, n);
|
|
1442
1451
|
};
|
|
1443
1452
|
let r = e.elapsedTime / 1e3, a = n.collidable ?? [];
|
|
1444
1453
|
if (!i) {
|
|
@@ -1447,7 +1456,7 @@ function Qn(e = {}) {
|
|
|
1447
1456
|
}
|
|
1448
1457
|
let l = /* @__PURE__ */ new Map();
|
|
1449
1458
|
for (let t of a) {
|
|
1450
|
-
let n =
|
|
1459
|
+
let n = tr(t.components, i);
|
|
1451
1460
|
if (e.skipGroup === n) continue;
|
|
1452
1461
|
let r = l.get(n);
|
|
1453
1462
|
r || (r = [], l.set(n, r)), r.push(t);
|
|
@@ -1456,7 +1465,7 @@ function Qn(e = {}) {
|
|
|
1456
1465
|
for (let [t, n] of l) s.set(t, new Sn(n, r, e.dynamicsCommands));
|
|
1457
1466
|
}, l;
|
|
1458
1467
|
}
|
|
1459
|
-
function
|
|
1468
|
+
function er(e, t) {
|
|
1460
1469
|
let n = e, r = e.commandQueueId ?? 0, i = t.get(r);
|
|
1461
1470
|
i && (e.dynamicsCommands = Gn(i, e.dynamicsCommands), t.delete(r));
|
|
1462
1471
|
let a = () => {
|
|
@@ -1471,26 +1480,26 @@ function $n(e, t) {
|
|
|
1471
1480
|
Yn(a(), e, t);
|
|
1472
1481
|
};
|
|
1473
1482
|
}
|
|
1474
|
-
function
|
|
1483
|
+
function tr(e, t) {
|
|
1475
1484
|
let n = e[t.component];
|
|
1476
1485
|
return n ? n[t.index] : 0;
|
|
1477
1486
|
}
|
|
1478
|
-
function
|
|
1487
|
+
function nr(e, t, n, r, i, a, o, s, c, l) {
|
|
1479
1488
|
if (Ln(n, r, c), !l) return;
|
|
1480
1489
|
let u = J(n.components), d = J(r.components);
|
|
1481
1490
|
Zn.x = 0, Zn.y = 0, t.contactNormal(n, r, o, s, Zn), l(e, n, r, i, a, {
|
|
1482
1491
|
normalX: Zn.x,
|
|
1483
1492
|
normalY: Zn.y
|
|
1484
|
-
}),
|
|
1493
|
+
}), rr(e, n.entityId, n.components, u), rr(e, r.entityId, r.components, d);
|
|
1485
1494
|
}
|
|
1486
|
-
function
|
|
1495
|
+
function rr(e, t, n, r) {
|
|
1487
1496
|
let i = J(n);
|
|
1488
1497
|
(i.minX !== r.minX || i.minY !== r.minY || i.maxX !== r.maxX || i.maxY !== r.maxY) && Q(e, t, n);
|
|
1489
1498
|
}
|
|
1490
|
-
function
|
|
1499
|
+
function ir(e, t, n, r) {
|
|
1491
1500
|
let i = n.components.body;
|
|
1492
|
-
if (!i ||
|
|
1493
|
-
|
|
1501
|
+
if (!i || Ae(i)) return;
|
|
1502
|
+
je(i);
|
|
1494
1503
|
let a = n.components.transform, o = n.components.velocity, s = r.components.transform, c = r.components.body;
|
|
1495
1504
|
if (!t || !a || !o || !s || !c) return;
|
|
1496
1505
|
let l = e.elapsedTime / 1e3, u = o[0] * l, d = o[1] * l;
|
|
@@ -1507,44 +1516,44 @@ function rr(e, t, n, r) {
|
|
|
1507
1516
|
} }, u, d);
|
|
1508
1517
|
a[0] = f.x, a[1] = f.y;
|
|
1509
1518
|
}
|
|
1510
|
-
function
|
|
1519
|
+
function ar(e, t, n, r, i) {
|
|
1511
1520
|
let a = e.elapsedTime / 1e3, o = n.interpolation;
|
|
1512
|
-
Fn(e, t, n.velocity, n.dynamics),
|
|
1521
|
+
Fn(e, t, n.velocity, n.dynamics), or(o, n.transform, e), cr(t, n.transform, n.velocity[0] * a, n.velocity[1] * a, i, e.reportMoves), Q(e, t, n), sr(o, e.tick);
|
|
1513
1522
|
}
|
|
1514
|
-
function
|
|
1523
|
+
function or(e, t, n) {
|
|
1515
1524
|
e && (a(e, 16, NaN), e[12] = t[0], e[13] = t[1], e[14] = e[3], e[15] = e[5], a(e, 16, i(e, 4)), a(e, 4, NaN), e[11] = n.interpolationChannel ?? 0, e[3] = n.elapsedTime, e[5] += n.elapsedTime);
|
|
1516
1525
|
}
|
|
1517
|
-
function
|
|
1526
|
+
function sr(e, t) {
|
|
1518
1527
|
e && a(e, 4, t);
|
|
1519
1528
|
}
|
|
1520
|
-
function
|
|
1529
|
+
function cr(e, t, n, r, i, a) {
|
|
1521
1530
|
(n !== 0 || r !== 0) && (n !== 0 && c(t, 0, n, Infinity), r !== 0 && c(t, 1, r, Infinity), a !== !1 && i.emitSystemEvent(l, e));
|
|
1522
1531
|
}
|
|
1523
1532
|
// src/systems/interpolation-channels.ts
|
|
1524
|
-
var
|
|
1525
|
-
function lr(e, t) {
|
|
1526
|
-
let n = cr.get(e);
|
|
1527
|
-
return n || (n = [void 0], cr.set(e, n)), n.push(t), n.length - 1;
|
|
1528
|
-
}
|
|
1533
|
+
var lr = /* @__PURE__ */ new WeakMap();
|
|
1529
1534
|
function ur(e, t) {
|
|
1530
|
-
let n =
|
|
1535
|
+
let n = lr.get(e);
|
|
1536
|
+
return n || (n = [void 0], lr.set(e, n)), n.push(t), n.length - 1;
|
|
1537
|
+
}
|
|
1538
|
+
function dr(e, t) {
|
|
1539
|
+
let n = lr.get(e);
|
|
1531
1540
|
n && t > 0 && t < n.length && (n[t] = void 0);
|
|
1532
1541
|
}
|
|
1533
|
-
function
|
|
1534
|
-
let t =
|
|
1542
|
+
function fr(e) {
|
|
1543
|
+
let t = lr.get(e);
|
|
1535
1544
|
if (t) return t.map((e) => e ? e.committedTick : NaN);
|
|
1536
1545
|
}
|
|
1537
1546
|
// src/systems/physics-system.ts
|
|
1538
|
-
var
|
|
1547
|
+
var pr = 1, mr = class extends r {
|
|
1539
1548
|
spatialWorld;
|
|
1540
1549
|
pendingDynamicsCommands = /* @__PURE__ */ new Map();
|
|
1541
|
-
commandQueueId =
|
|
1550
|
+
commandQueueId = pr++;
|
|
1542
1551
|
tick = 0;
|
|
1543
1552
|
interpolationChannel;
|
|
1544
1553
|
reportMoves;
|
|
1545
1554
|
skipGroup;
|
|
1546
1555
|
constructor(e, t = {}) {
|
|
1547
|
-
let n = t.updateFunction ??
|
|
1556
|
+
let n = t.updateFunction ?? ar, r = t.optional ?? n.physics?.optional ?? [], i = t.collision ?? n.physics?.collision ?? !1, a = n === ar || n.physics?.dynamics === !0, o = n.physics?.group, s = [];
|
|
1548
1557
|
i && !r.includes("body") && s.push("body"), i && !r.includes("bounciness") && s.push("bounciness"), i && !r.includes("polygon") && s.push("polygon"), r.includes("interpolation") || s.push("interpolation"), a && !r.includes("dynamics") && s.push("dynamics"), i && s.push("entity"), o && !r.includes(o.component) && s.push(o.component);
|
|
1549
1558
|
let c = s.length ? [...s, ...r] : r, l = r.includes("bounciness") ? [...r] : ["bounciness", ...r];
|
|
1550
1559
|
l.includes("polygon") || l.push("polygon"), a && !l.includes("dynamics") && l.push("dynamics"), o && !l.includes(o.component) && l.push(o.component);
|
|
@@ -1559,11 +1568,14 @@ var fr = 1, pr = class extends r {
|
|
|
1559
1568
|
} } : void 0, f = d || t.queries ? {
|
|
1560
1569
|
...d,
|
|
1561
1570
|
...t.queries
|
|
1562
|
-
} : void 0, p =
|
|
1571
|
+
} : void 0, p = hr(t.scope, t.filter);
|
|
1563
1572
|
super(e, {
|
|
1564
1573
|
name: t.name ?? "PhysicsSystem",
|
|
1565
1574
|
deltaBetweenRuns: t.deltaBetweenRuns ?? 50,
|
|
1566
1575
|
firstRun: t.firstRun,
|
|
1576
|
+
reads: t.reads,
|
|
1577
|
+
writes: [.../* @__PURE__ */ new Set([...n.physics?.writes ?? Qn, ...t.writes ?? []])],
|
|
1578
|
+
exclusive: t.exclusive,
|
|
1567
1579
|
required: ["transform", "velocity"],
|
|
1568
1580
|
optional: c,
|
|
1569
1581
|
filter: p,
|
|
@@ -1573,13 +1585,13 @@ var fr = 1, pr = class extends r {
|
|
|
1573
1585
|
getWorker: t.getWorker ?? (() => {
|
|
1574
1586
|
throw Error("PhysicsSystem cannot start a worker: no getWorker was supplied");
|
|
1575
1587
|
})
|
|
1576
|
-
}), this.spatialWorld = e, this.reportMoves = t.reportMoves, this.skipGroup = t.skipGroup, this.interpolationChannel =
|
|
1588
|
+
}), this.spatialWorld = e, this.reportMoves = t.reportMoves, this.skipGroup = t.skipGroup, this.interpolationChannel = ur(e, this);
|
|
1577
1589
|
}
|
|
1578
1590
|
get committedTick() {
|
|
1579
1591
|
return this.isCurrentlyRunning() ? this.tick - 1 : this.tick;
|
|
1580
1592
|
}
|
|
1581
1593
|
destroy() {
|
|
1582
|
-
|
|
1594
|
+
dr(this.world, this.interpolationChannel), super.destroy();
|
|
1583
1595
|
}
|
|
1584
1596
|
startInterpolation(e) {
|
|
1585
1597
|
let t = this.deltaBetweenRuns;
|
|
@@ -1620,11 +1632,11 @@ var fr = 1, pr = class extends r {
|
|
|
1620
1632
|
return n;
|
|
1621
1633
|
}
|
|
1622
1634
|
};
|
|
1623
|
-
function
|
|
1635
|
+
function hr(e, t) {
|
|
1624
1636
|
return e ? t ? (n) => e(n) && t(n) : e : t;
|
|
1625
1637
|
}
|
|
1626
1638
|
// src/pathfinding/nav-grid.ts
|
|
1627
|
-
var
|
|
1639
|
+
var gr = 0, _r = class e {
|
|
1628
1640
|
tilesWide;
|
|
1629
1641
|
tilesHigh;
|
|
1630
1642
|
cellSize;
|
|
@@ -1711,14 +1723,14 @@ var hr = 0, gr = class e {
|
|
|
1711
1723
|
return this.cellSize / this.speeds[this.index(e, t)];
|
|
1712
1724
|
}
|
|
1713
1725
|
region(e, t) {
|
|
1714
|
-
return this.inBounds(e, t) ? (this.regionsDirty && this.rebuildRegions(), this.regions[this.index(e, t)]) :
|
|
1726
|
+
return this.inBounds(e, t) ? (this.regionsDirty && this.rebuildRegions(), this.regions[this.index(e, t)]) : gr;
|
|
1715
1727
|
}
|
|
1716
1728
|
rebuildRegions() {
|
|
1717
1729
|
let e = this.regions;
|
|
1718
|
-
e.fill(
|
|
1719
|
-
let t = new Int32Array(this.tileCount), n =
|
|
1730
|
+
e.fill(gr);
|
|
1731
|
+
let t = new Int32Array(this.tileCount), n = gr;
|
|
1720
1732
|
for (let r = 0; r < e.length; r++) {
|
|
1721
|
-
if (e[r] !==
|
|
1733
|
+
if (e[r] !== gr || this.blockers[r] > 0) continue;
|
|
1722
1734
|
n++, e[r] = n;
|
|
1723
1735
|
let i = 0, a = 0;
|
|
1724
1736
|
for (t[a++] = r; i < a;) {
|
|
@@ -1731,9 +1743,9 @@ var hr = 0, gr = class e {
|
|
|
1731
1743
|
flood(e, t, n, r, i) {
|
|
1732
1744
|
if (!this.inBounds(e, t)) return i;
|
|
1733
1745
|
let a = this.index(e, t);
|
|
1734
|
-
return this.regions[a] !==
|
|
1746
|
+
return this.regions[a] !== gr || this.blockers[a] > 0 ? i : (this.regions[a] = n, r[i] = a, i + 1);
|
|
1735
1747
|
}
|
|
1736
|
-
},
|
|
1748
|
+
}, vr = class {
|
|
1737
1749
|
ids;
|
|
1738
1750
|
primary;
|
|
1739
1751
|
secondary;
|
|
@@ -1785,7 +1797,7 @@ var hr = 0, gr = class e {
|
|
|
1785
1797
|
}
|
|
1786
1798
|
};
|
|
1787
1799
|
// src/pathfinding/line-of-sight.ts
|
|
1788
|
-
function
|
|
1800
|
+
function yr(e, t, n, r, i, a, o) {
|
|
1789
1801
|
let s = e.cellSize, c = r - t, l = i - n, u = o + s / 2, d = Math.floor((Math.min(n, i) - o) / s), f = Math.ceil((Math.max(n, i) + o) / s) - 1, p = 0;
|
|
1790
1802
|
for (let r = d; r <= f; r++) {
|
|
1791
1803
|
let i = (r + .5) * s, o, d;
|
|
@@ -1807,34 +1819,34 @@ function vr(e, t, n, r, i, a, o) {
|
|
|
1807
1819
|
return p;
|
|
1808
1820
|
}
|
|
1809
1821
|
// src/pathfinding/smooth-path.ts
|
|
1810
|
-
var
|
|
1811
|
-
function
|
|
1812
|
-
let a =
|
|
1822
|
+
var br = 24;
|
|
1823
|
+
function xr(e, t, n, r, i) {
|
|
1824
|
+
let a = wr(t);
|
|
1813
1825
|
if (a.length <= 2) return a;
|
|
1814
1826
|
let o = new Float64Array(a.length);
|
|
1815
|
-
for (let t = 1; t < a.length; t++) o[t] = o[t - 1] +
|
|
1827
|
+
for (let t = 1; t < a.length; t++) o[t] = o[t - 1] + Sr(e, a[t - 1], a[t], n, r);
|
|
1816
1828
|
let s = [0];
|
|
1817
|
-
for (let e = 1; e < a.length - 1; e++)
|
|
1829
|
+
for (let e = 1; e < a.length - 1; e++) Cr(a[e - 1], a[e], a[e + 1]) || s.push(e);
|
|
1818
1830
|
s.push(a.length - 1);
|
|
1819
1831
|
let c = [a[0]], l = 0;
|
|
1820
1832
|
for (; l < s.length - 1;) {
|
|
1821
|
-
let t = l + 1, u = Math.min(s.length - 1, l +
|
|
1833
|
+
let t = l + 1, u = Math.min(s.length - 1, l + br);
|
|
1822
1834
|
for (let c = l + 2; c <= u; c++) {
|
|
1823
|
-
let u = a[s[l]], d = a[s[c]], f =
|
|
1835
|
+
let u = a[s[l]], d = a[s[c]], f = yr(e, u.x, u.y, d.x, d.y, n + i, r + i), p = Math.hypot(d.x - u.x, d.y - u.y) * f;
|
|
1824
1836
|
Number.isFinite(p) && p <= o[s[c]] - o[s[l]] + 1e-6 && (t = c);
|
|
1825
1837
|
}
|
|
1826
1838
|
c.push(a[s[t]]), l = t;
|
|
1827
1839
|
}
|
|
1828
1840
|
return c;
|
|
1829
1841
|
}
|
|
1830
|
-
function
|
|
1831
|
-
let a = Math.hypot(n.x - t.x, n.y - t.y), o =
|
|
1842
|
+
function Sr(e, t, n, r, i) {
|
|
1843
|
+
let a = Math.hypot(n.x - t.x, n.y - t.y), o = yr(e, t.x, t.y, n.x, n.y, r, i);
|
|
1832
1844
|
return a * (Number.isFinite(o) ? o : 1 / e.terrainSpeed(e.tileOf(n.x), e.tileOf(n.y)));
|
|
1833
1845
|
}
|
|
1834
|
-
function
|
|
1846
|
+
function Cr(e, t, n) {
|
|
1835
1847
|
return Math.abs((t.x - e.x) * (n.y - t.y) - (t.y - e.y) * (n.x - t.x)) < 1e-9 && (t.x - e.x) * (n.x - t.x) + (t.y - e.y) * (n.y - t.y) > 0;
|
|
1836
1848
|
}
|
|
1837
|
-
function
|
|
1849
|
+
function wr(e) {
|
|
1838
1850
|
let t = [];
|
|
1839
1851
|
for (let n of e) {
|
|
1840
1852
|
let e = t[t.length - 1];
|
|
@@ -1843,35 +1855,35 @@ function Cr(e) {
|
|
|
1843
1855
|
return t;
|
|
1844
1856
|
}
|
|
1845
1857
|
// src/pathfinding/grid-a-star.ts
|
|
1846
|
-
var
|
|
1858
|
+
var Tr = 5e4, Er = 0, Dr = 16, Or = [
|
|
1847
1859
|
[-1, 0],
|
|
1848
1860
|
[1, 0],
|
|
1849
1861
|
[0, -1],
|
|
1850
1862
|
[0, 1]
|
|
1851
|
-
],
|
|
1863
|
+
], kr = [
|
|
1852
1864
|
[-1, -1],
|
|
1853
1865
|
[1, -1],
|
|
1854
1866
|
[-1, 1],
|
|
1855
1867
|
[1, 1]
|
|
1856
|
-
],
|
|
1868
|
+
], Ar = class {
|
|
1857
1869
|
diagonal;
|
|
1858
1870
|
maxIterations;
|
|
1859
1871
|
smooth;
|
|
1860
1872
|
clearance;
|
|
1861
1873
|
relocateRadius;
|
|
1862
|
-
heap = new
|
|
1874
|
+
heap = new vr(256);
|
|
1863
1875
|
cost = /* @__PURE__ */ new Float64Array();
|
|
1864
1876
|
parent = /* @__PURE__ */ new Int32Array();
|
|
1865
1877
|
seen = /* @__PURE__ */ new Uint32Array();
|
|
1866
1878
|
closed = /* @__PURE__ */ new Uint32Array();
|
|
1867
1879
|
stamp = 0;
|
|
1868
1880
|
constructor(e = {}) {
|
|
1869
|
-
this.diagonal = e.diagonal ?? !1, this.maxIterations = e.maxIterations ??
|
|
1881
|
+
this.diagonal = e.diagonal ?? !1, this.maxIterations = e.maxIterations ?? Tr, this.smooth = e.smooth ?? !0, this.clearance = e.clearance ?? Er, this.relocateRadius = e.relocateRadius ?? Dr;
|
|
1870
1882
|
}
|
|
1871
1883
|
findPath(e, t) {
|
|
1872
1884
|
let n = e.cellSize, r = Math.max(1, Math.ceil(t.agentWidth / n - 1e-9)), i = Math.max(1, Math.ceil(t.agentHeight / n - 1e-9));
|
|
1873
1885
|
if (r > e.tilesWide || i > e.tilesHigh) return {
|
|
1874
|
-
status:
|
|
1886
|
+
status: L.Unreachable,
|
|
1875
1887
|
points: [],
|
|
1876
1888
|
iterations: 0
|
|
1877
1889
|
};
|
|
@@ -1879,14 +1891,14 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1879
1891
|
x: Math.round((e - r * n / 2) / n),
|
|
1880
1892
|
y: Math.round((t - i * n / 2) / n)
|
|
1881
1893
|
}), o = (t) => ({
|
|
1882
|
-
x:
|
|
1883
|
-
y:
|
|
1894
|
+
x: Mr(t.x, 0, e.tilesWide - r),
|
|
1895
|
+
y: Mr(t.y, 0, e.tilesHigh - i)
|
|
1884
1896
|
}), s = (e) => ({
|
|
1885
1897
|
x: (e.x + r / 2) * n,
|
|
1886
1898
|
y: (e.y + i / 2) * n
|
|
1887
1899
|
}), c = this.relocate(e, o(a(t.startX, t.startY)), r, i, t.startX, t.startY, t.goalX, t.goalY), l = a(t.goalX, t.goalY), u = this.relocate(e, o(l), r, i, t.goalX, t.goalY, t.startX, t.startY);
|
|
1888
1900
|
if (!c || !u || e.region(c.x, c.y) !== e.region(u.x, u.y)) return {
|
|
1889
|
-
status:
|
|
1901
|
+
status: L.Unreachable,
|
|
1890
1902
|
points: [],
|
|
1891
1903
|
iterations: 0
|
|
1892
1904
|
};
|
|
@@ -1899,14 +1911,14 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1899
1911
|
y: Math.floor(t / e.tilesWide)
|
|
1900
1912
|
}));
|
|
1901
1913
|
let m = f.status;
|
|
1902
|
-
if (m ===
|
|
1914
|
+
if (m === L.Found) {
|
|
1903
1915
|
let n = s(u);
|
|
1904
|
-
d || !Number.isFinite(
|
|
1916
|
+
d || !Number.isFinite(yr(e, n.x, n.y, t.goalX, t.goalY, t.agentWidth / 2, t.agentHeight / 2)) ? m = L.Unreachable : p.push({
|
|
1905
1917
|
x: t.goalX,
|
|
1906
1918
|
y: t.goalY
|
|
1907
1919
|
});
|
|
1908
1920
|
}
|
|
1909
|
-
let h = t.agentWidth / 2, g = t.agentHeight / 2, _ = this.smooth ?
|
|
1921
|
+
let h = t.agentWidth / 2, g = t.agentHeight / 2, _ = this.smooth ? xr(e, p, h, g, this.clearance) : Nr(p);
|
|
1910
1922
|
return {
|
|
1911
1923
|
status: m,
|
|
1912
1924
|
points: _.slice(1),
|
|
@@ -1944,23 +1956,23 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1944
1956
|
let t = u.pop();
|
|
1945
1957
|
if (l[t] === a) continue;
|
|
1946
1958
|
if (t === p) return {
|
|
1947
|
-
status:
|
|
1959
|
+
status: L.Found,
|
|
1948
1960
|
tiles: this.trace(t),
|
|
1949
1961
|
iterations: v
|
|
1950
1962
|
};
|
|
1951
1963
|
if (v >= this.maxIterations) return {
|
|
1952
|
-
status:
|
|
1964
|
+
status: L.Incomplete,
|
|
1953
1965
|
tiles: this.trace(g),
|
|
1954
1966
|
iterations: v
|
|
1955
1967
|
};
|
|
1956
1968
|
l[t] = a, v++;
|
|
1957
1969
|
let n = t % d, s = (t - n) / d, c = h(n, s);
|
|
1958
1970
|
(c < _ || c === _ && o[t] < o[g]) && (g = t, _ = c);
|
|
1959
|
-
for (let [a, o] of
|
|
1960
|
-
if (this.diagonal) for (let [a, o] of
|
|
1971
|
+
for (let [a, o] of Or) this.relax(e, t, n + a, s + o, 1, r, i, h);
|
|
1972
|
+
if (this.diagonal) for (let [a, o] of kr) e.isAreaClear(n + a, s, r, i) && e.isAreaClear(n, s + o, r, i) && this.relax(e, t, n + a, s + o, Math.SQRT2, r, i, h);
|
|
1961
1973
|
}
|
|
1962
1974
|
return {
|
|
1963
|
-
status:
|
|
1975
|
+
status: L.Unreachable,
|
|
1964
1976
|
tiles: this.trace(g),
|
|
1965
1977
|
iterations: v
|
|
1966
1978
|
};
|
|
@@ -1969,7 +1981,7 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1969
1981
|
if (!e.isAreaClear(n, r, a, o)) return;
|
|
1970
1982
|
let c = e.index(n, r);
|
|
1971
1983
|
if (this.closed[c] === this.stamp) return;
|
|
1972
|
-
let l = this.cost[t] + i *
|
|
1984
|
+
let l = this.cost[t] + i * jr(e, n, r, a, o);
|
|
1973
1985
|
if (this.seen[c] === this.stamp && l >= this.cost[c]) return;
|
|
1974
1986
|
this.seen[c] = this.stamp, this.cost[c] = l, this.parent[c] = t;
|
|
1975
1987
|
let u = s(n, r);
|
|
@@ -1986,16 +1998,16 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1986
1998
|
this.cost.length !== e && (this.cost = new Float64Array(e), this.parent = new Int32Array(e), this.seen = new Uint32Array(e), this.closed = new Uint32Array(e), this.stamp = 0), this.stamp++, this.stamp === 4294967295 && (this.seen.fill(0), this.closed.fill(0), this.stamp = 1);
|
|
1987
1999
|
}
|
|
1988
2000
|
};
|
|
1989
|
-
function
|
|
2001
|
+
function jr(e, t, n, r, i) {
|
|
1990
2002
|
if (r === 1 && i === 1) return e.cost(t, n);
|
|
1991
2003
|
let a = 0;
|
|
1992
2004
|
for (let o = n; o < n + i; o++) for (let n = t; n < t + r; n++) a += e.cost(n, o);
|
|
1993
2005
|
return a / (r * i);
|
|
1994
2006
|
}
|
|
1995
|
-
function
|
|
2007
|
+
function Mr(e, t, n) {
|
|
1996
2008
|
return Math.min(n, Math.max(t, e));
|
|
1997
2009
|
}
|
|
1998
|
-
function
|
|
2010
|
+
function Nr(e) {
|
|
1999
2011
|
return e.filter((t, n) => n === 0 || t.x !== e[n - 1].x || t.y !== e[n - 1].y);
|
|
2000
2012
|
}
|
|
2001
2013
|
// src/pathfinding/follow-path.ts
|
|
@@ -2005,17 +2017,17 @@ var $ = {
|
|
|
2005
2017
|
Goal: 2,
|
|
2006
2018
|
Stuck: 3
|
|
2007
2019
|
};
|
|
2008
|
-
function
|
|
2009
|
-
if (
|
|
2020
|
+
function Pr(e, t, n, r, a) {
|
|
2021
|
+
if (wt(e)) return $.Waiting;
|
|
2010
2022
|
let o = e[4], s = e[3];
|
|
2011
|
-
for (; s < o && Math.hypot(
|
|
2012
|
-
if (e[3] = s, s < o) return a.x =
|
|
2023
|
+
for (; s < o && Math.hypot(Ot(e, s) - t, kt(e, s) - n) <= r;) s++;
|
|
2024
|
+
if (e[3] = s, s < o) return a.x = Ot(e, s), a.y = kt(e, s), $.Waypoint;
|
|
2013
2025
|
let c = e[2];
|
|
2014
|
-
return c ===
|
|
2026
|
+
return c === L.Incomplete ? (Ct(e), $.Waiting) : c === L.Found ? (a.x = i(e, 6), a.y = i(e, 7), $.Goal) : $.Stuck;
|
|
2015
2027
|
}
|
|
2016
2028
|
// src/pathfinding/path-blockers.ts
|
|
2017
|
-
var
|
|
2018
|
-
function
|
|
2029
|
+
var Fr = "pathBlockers", Ir = "pathGates";
|
|
2030
|
+
function Lr(e = {}) {
|
|
2019
2031
|
let { gateCategories: t = 0, not: n, filter: r } = e, i = {
|
|
2020
2032
|
required: ["transform", "body"],
|
|
2021
2033
|
not: n,
|
|
@@ -2024,7 +2036,7 @@ function Ir(e = {}) {
|
|
|
2024
2036
|
return !!t && t.blocksPath && !t.sensor && (!r || r(e));
|
|
2025
2037
|
}
|
|
2026
2038
|
};
|
|
2027
|
-
if (!t) return { [
|
|
2039
|
+
if (!t) return { [Fr]: i };
|
|
2028
2040
|
let a = {
|
|
2029
2041
|
required: ["transform", "body"],
|
|
2030
2042
|
not: n,
|
|
@@ -2034,12 +2046,12 @@ function Ir(e = {}) {
|
|
|
2034
2046
|
}
|
|
2035
2047
|
};
|
|
2036
2048
|
return {
|
|
2037
|
-
[
|
|
2038
|
-
[
|
|
2049
|
+
[Fr]: i,
|
|
2050
|
+
[Ir]: a
|
|
2039
2051
|
};
|
|
2040
2052
|
}
|
|
2041
|
-
function
|
|
2042
|
-
let n = t[0] & 7, r = e[2], i = e[3], a =
|
|
2053
|
+
function Rr(e, t) {
|
|
2054
|
+
let n = t[0] & 7, r = e[2], i = e[3], a = Br(e[4]), o = H(n, r, i, a), s = U(n, r, i, a), c = e[0], l = e[1];
|
|
2043
2055
|
return {
|
|
2044
2056
|
minX: c - o,
|
|
2045
2057
|
minY: l - s,
|
|
@@ -2047,7 +2059,7 @@ function Lr(e, t) {
|
|
|
2047
2059
|
maxY: l + s
|
|
2048
2060
|
};
|
|
2049
2061
|
}
|
|
2050
|
-
function
|
|
2062
|
+
function zr(e, t, n) {
|
|
2051
2063
|
let r = [...t];
|
|
2052
2064
|
for (let t of n.removed) {
|
|
2053
2065
|
let n = e.get(t);
|
|
@@ -2061,26 +2073,26 @@ function Rr(e, t, n) {
|
|
|
2061
2073
|
e.delete(t);
|
|
2062
2074
|
continue;
|
|
2063
2075
|
}
|
|
2064
|
-
let s =
|
|
2076
|
+
let s = Rr(a, o);
|
|
2065
2077
|
r.forEach((e) => e.addBlocker(s)), e.set(t, s);
|
|
2066
2078
|
}
|
|
2067
2079
|
return n.added.length > 0;
|
|
2068
2080
|
}
|
|
2069
|
-
function
|
|
2081
|
+
function Br(e) {
|
|
2070
2082
|
let t = Math.round(e / (Math.PI / 2)) * Math.PI / 2;
|
|
2071
2083
|
return Math.abs(e - t) < 1e-5 ? t : e;
|
|
2072
2084
|
}
|
|
2073
2085
|
// src/pathfinding/navigation-state.ts
|
|
2074
|
-
function
|
|
2086
|
+
function Vr(e, t, n, r = 0) {
|
|
2075
2087
|
return {
|
|
2076
|
-
grid: new
|
|
2088
|
+
grid: new _r(e, t, n),
|
|
2077
2089
|
blockers: /* @__PURE__ */ new Map(),
|
|
2078
2090
|
gateCategories: r,
|
|
2079
2091
|
gates: /* @__PURE__ */ new Map(),
|
|
2080
2092
|
gatedGrids: /* @__PURE__ */ new Map()
|
|
2081
2093
|
};
|
|
2082
2094
|
}
|
|
2083
|
-
function
|
|
2095
|
+
function Hr(e, t) {
|
|
2084
2096
|
let n = t & e.gateCategories;
|
|
2085
2097
|
if (!n) return e.grid;
|
|
2086
2098
|
let r = e.gatedGrids.get(n);
|
|
@@ -2091,51 +2103,51 @@ function Vr(e, t) {
|
|
|
2091
2103
|
}
|
|
2092
2104
|
return r;
|
|
2093
2105
|
}
|
|
2094
|
-
function
|
|
2106
|
+
function Ur(e, t) {
|
|
2095
2107
|
let n = t & e.gateCategories, r = [...e.blockers.values()];
|
|
2096
2108
|
if (n) for (let t of e.gates.values()) t.category & n && r.push(t.rect);
|
|
2097
2109
|
return r;
|
|
2098
2110
|
}
|
|
2099
|
-
function
|
|
2111
|
+
function Wr(e, t, n, r) {
|
|
2100
2112
|
e.grid.setTerrainSpeed(t, n, r);
|
|
2101
2113
|
for (let i of e.gatedGrids.values()) i.setTerrainSpeed(t, n, r);
|
|
2102
2114
|
}
|
|
2103
|
-
function Wr(e, t) {
|
|
2104
|
-
return Rr(e.blockers, [e.grid, ...e.gatedGrids.values()], t);
|
|
2105
|
-
}
|
|
2106
2115
|
function Gr(e, t) {
|
|
2116
|
+
return zr(e.blockers, [e.grid, ...e.gatedGrids.values()], t);
|
|
2117
|
+
}
|
|
2118
|
+
function Kr(e, t) {
|
|
2107
2119
|
for (let n of t.removed) {
|
|
2108
2120
|
let t = e.gates.get(n);
|
|
2109
|
-
t && (
|
|
2121
|
+
t && (qr(e, t.category, (e) => e.removeBlocker(t.rect)), e.gates.delete(n));
|
|
2110
2122
|
}
|
|
2111
2123
|
for (let { entityId: n, components: r } of t.added) {
|
|
2112
2124
|
let t = e.gates.get(n);
|
|
2113
|
-
t &&
|
|
2125
|
+
t && qr(e, t.category, (e) => e.removeBlocker(t.rect));
|
|
2114
2126
|
let { transform: i, body: a } = r;
|
|
2115
2127
|
if (!(i instanceof Float32Array) || !(a instanceof Uint32Array)) {
|
|
2116
2128
|
e.gates.delete(n);
|
|
2117
2129
|
continue;
|
|
2118
2130
|
}
|
|
2119
2131
|
let o = {
|
|
2120
|
-
rect:
|
|
2132
|
+
rect: Rr(i, a),
|
|
2121
2133
|
category: a[1] & e.gateCategories
|
|
2122
2134
|
};
|
|
2123
|
-
|
|
2135
|
+
qr(e, o.category, (e) => e.addBlocker(o.rect)), e.gates.set(n, o);
|
|
2124
2136
|
}
|
|
2125
2137
|
return t.added.length > 0;
|
|
2126
2138
|
}
|
|
2127
|
-
function
|
|
2139
|
+
function qr(e, t, n) {
|
|
2128
2140
|
for (let [r, i] of e.gatedGrids) r & t && n(i);
|
|
2129
2141
|
}
|
|
2130
2142
|
// src/pathfinding/pathfinding-update.ts
|
|
2131
|
-
var
|
|
2132
|
-
function
|
|
2133
|
-
let t = e.search ?? new
|
|
2143
|
+
var Jr = 16e3;
|
|
2144
|
+
function Yr(e = {}) {
|
|
2145
|
+
let t = e.search ?? new Ar({ diagonal: !0 }), n = e.iterationBudget ?? 16e3, r = e.gateCategories ?? 0, a = (e, r, a) => {
|
|
2134
2146
|
let { navigation: o, transform: s, body: c } = a;
|
|
2135
2147
|
if (!o[5]) return;
|
|
2136
|
-
let l = c ? c[2] : 0, u =
|
|
2148
|
+
let l = c ? c[2] : 0, u = Hr(e.navigation, l), d = Atomics.load(o, 0);
|
|
2137
2149
|
if (d === Atomics.load(o, 1)) {
|
|
2138
|
-
if (!e.blockersAdded ||
|
|
2150
|
+
if (!e.blockersAdded || Qr(u, o, s)) return;
|
|
2139
2151
|
d = Atomics.add(o, 0, 1) + 1;
|
|
2140
2152
|
}
|
|
2141
2153
|
if ((e.searchIterations ?? 0) >= (e.iterationBudget ?? n)) return;
|
|
@@ -2146,19 +2158,19 @@ function Jr(e = {}) {
|
|
|
2146
2158
|
goalY: i(o, 7),
|
|
2147
2159
|
agentWidth: s[2],
|
|
2148
2160
|
agentHeight: s[3]
|
|
2149
|
-
}, p =
|
|
2161
|
+
}, p = Zr(e.navigation, u, l, f);
|
|
2150
2162
|
p.forEach((e) => u.removeBlocker(e));
|
|
2151
2163
|
let m = t.findPath(u, f);
|
|
2152
2164
|
p.forEach((e) => u.addBlocker(e)), e.searchIterations = (e.searchIterations ?? 0) + m.iterations;
|
|
2153
|
-
let h = m.status ===
|
|
2154
|
-
At(o, m.status ===
|
|
2165
|
+
let h = m.status === L.Found ? m.points.slice(0, -1) : m.points;
|
|
2166
|
+
At(o, m.status === L.Incomplete && h.length === 0 ? L.Unreachable : m.status, h), Atomics.store(o, 1, d);
|
|
2155
2167
|
};
|
|
2156
2168
|
return a.init = (t, n, i, a) => {
|
|
2157
|
-
let o =
|
|
2158
|
-
return
|
|
2169
|
+
let o = Vr(n?.tilesWide ?? 1, n?.tilesHigh ?? 1, n?.cellSize ?? 1, r);
|
|
2170
|
+
return Gr(o, {
|
|
2159
2171
|
added: a.pathBlockers ?? [],
|
|
2160
2172
|
removed: []
|
|
2161
|
-
}),
|
|
2173
|
+
}), Kr(o, {
|
|
2162
2174
|
added: a.pathGates ?? [],
|
|
2163
2175
|
removed: []
|
|
2164
2176
|
}), {
|
|
@@ -2166,13 +2178,13 @@ function Jr(e = {}) {
|
|
|
2166
2178
|
navigation: o
|
|
2167
2179
|
};
|
|
2168
2180
|
}, a.queryChanged = (t, n, r, i) => {
|
|
2169
|
-
n === "pathBlockers" ? t.blockersAdded =
|
|
2181
|
+
n === "pathBlockers" ? t.blockersAdded = Gr(t.navigation, r) || !!t.blockersAdded : n === "pathGates" && (t.blockersAdded = Kr(t.navigation, r) || !!t.blockersAdded), e.queryChanged?.(t, n, r, i);
|
|
2170
2182
|
}, a.preRun = (t, n, r, i) => {
|
|
2171
2183
|
t.searchIterations = 0, e.preRun?.(t, n, r, i);
|
|
2172
2184
|
}, Object.assign(a, { pathfinding: { gateCategories: r } });
|
|
2173
2185
|
}
|
|
2174
|
-
var
|
|
2175
|
-
function
|
|
2186
|
+
var Xr = Yr();
|
|
2187
|
+
function Zr(e, t, n, r) {
|
|
2176
2188
|
let i = r.agentWidth / 2, a = r.agentHeight / 2, o = {
|
|
2177
2189
|
minX: r.startX - i,
|
|
2178
2190
|
minY: r.startY - a,
|
|
@@ -2180,33 +2192,36 @@ function Xr(e, t, n, r) {
|
|
|
2180
2192
|
maxY: r.startY + a
|
|
2181
2193
|
}, s = t.tilesIn(o), c = !0;
|
|
2182
2194
|
for (let e = s.fromY; e <= s.toY && c; e++) for (let n = s.fromX; n <= s.toX && c; n++) c = t.blockerCount(n, e) === 0;
|
|
2183
|
-
return c ? [] :
|
|
2195
|
+
return c ? [] : Ur(e, n).filter((e) => e.minX < o.maxX && e.maxX > o.minX && e.minY < o.maxY && e.maxY > o.minY);
|
|
2184
2196
|
}
|
|
2185
|
-
function
|
|
2197
|
+
function Qr(e, t, n) {
|
|
2186
2198
|
let r = n[2] / 2, a = n[3] / 2, o = n[0], s = n[1], c = t[4];
|
|
2187
2199
|
for (let n = t[3]; n <= c; n++) {
|
|
2188
2200
|
let l, u;
|
|
2189
|
-
if (n < c) l =
|
|
2190
|
-
else if (t[2] ===
|
|
2201
|
+
if (n < c) l = Ot(t, n), u = kt(t, n);
|
|
2202
|
+
else if (t[2] === L.Found) l = i(t, 6), u = i(t, 7);
|
|
2191
2203
|
else break;
|
|
2192
|
-
if (!Number.isFinite(
|
|
2204
|
+
if (!Number.isFinite(yr(e, o, s, l, u, r, a))) return !1;
|
|
2193
2205
|
o = l, s = u;
|
|
2194
2206
|
}
|
|
2195
2207
|
return !0;
|
|
2196
2208
|
}
|
|
2197
2209
|
// src/pathfinding/pathfinding-system.ts
|
|
2198
|
-
var
|
|
2210
|
+
var $r = class extends r {
|
|
2199
2211
|
iterationBudget;
|
|
2200
2212
|
constructor(e, t) {
|
|
2201
|
-
let n = t.updateFunction ??
|
|
2213
|
+
let n = t.updateFunction ?? Yr(), r = t.optional ?? [];
|
|
2202
2214
|
super(e, {
|
|
2203
2215
|
name: t.name ?? "PathfindingSystem",
|
|
2204
2216
|
deltaBetweenRuns: t.deltaBetweenRuns ?? 50,
|
|
2205
2217
|
firstRun: t.firstRun,
|
|
2218
|
+
reads: t.reads,
|
|
2219
|
+
writes: [.../* @__PURE__ */ new Set(["navigation", ...t.writes ?? []])],
|
|
2220
|
+
exclusive: t.exclusive,
|
|
2206
2221
|
required: ["navigation", "transform"],
|
|
2207
2222
|
optional: r.includes("body") ? r : ["body", ...r],
|
|
2208
2223
|
queries: {
|
|
2209
|
-
...
|
|
2224
|
+
...Lr({
|
|
2210
2225
|
...t.blockers,
|
|
2211
2226
|
gateCategories: n.pathfinding.gateCategories
|
|
2212
2227
|
}),
|
|
@@ -2230,7 +2245,7 @@ var Qr = class extends r {
|
|
|
2230
2245
|
finishLoading() {
|
|
2231
2246
|
return this.loaded = !0, super.finishLoading();
|
|
2232
2247
|
}
|
|
2233
|
-
},
|
|
2248
|
+
}, ei = (e, t, n) => {
|
|
2234
2249
|
let r = n.interpolation, a = n.transform, o = i(r, 4), s = r[3], c = r[5], l = a[0], u = a[1], d = i(r, 4), m = o === d, h = e.committedTicks?.[r[11]];
|
|
2235
2250
|
if (h !== void 0 && !Number.isNaN(h) && !(m && d <= h)) {
|
|
2236
2251
|
let e = i(r, 16);
|
|
@@ -2258,14 +2273,15 @@ var Qr = class extends r {
|
|
|
2258
2273
|
y > v && (_ += Math.min(y - v, _ * p));
|
|
2259
2274
|
let b = _ / g, x = r[0], S = r[1];
|
|
2260
2275
|
r[0] = x + (l - x) * b, r[1] = S + (u - S) * b, r[7] = g - _;
|
|
2261
|
-
},
|
|
2276
|
+
}, ti = class extends r {
|
|
2262
2277
|
constructor(e, t = {}) {
|
|
2263
2278
|
super(e, {
|
|
2264
2279
|
name: t.name ?? "InterpolationSystem",
|
|
2265
2280
|
deltaBetweenRuns: 0,
|
|
2266
2281
|
firstRun: t.firstRun,
|
|
2282
|
+
writes: ["interpolation"],
|
|
2267
2283
|
required: ["transform", "interpolation"],
|
|
2268
|
-
updateFunction:
|
|
2284
|
+
updateFunction: ei,
|
|
2269
2285
|
forceMainThread: t.forceMainThread ?? !t.getWorker,
|
|
2270
2286
|
getWorker: t.getWorker ?? (() => {
|
|
2271
2287
|
throw Error("InterpolationSystem cannot start a worker: no getWorker was supplied");
|
|
@@ -2273,9 +2289,9 @@ var Qr = class extends r {
|
|
|
2273
2289
|
});
|
|
2274
2290
|
}
|
|
2275
2291
|
addDataToWorld(e) {
|
|
2276
|
-
e.committedTicks =
|
|
2292
|
+
e.committedTicks = fr(this.world);
|
|
2277
2293
|
}
|
|
2278
2294
|
};
|
|
2279
|
-
export {
|
|
2295
|
+
export { Te as BODY_BLOCKS_PATH_FLAG, ve as BODY_CATEGORY_INDEX, Ce as BODY_CCD_FLAG, we as BODY_DYING_FLAG, _e as BODY_FLAGS_INDEX, ye as BODY_MASK_INDEX, Se as BODY_SENSOR_FLAG, xe as BODY_SHAPE_MASK, be as BODY_SIZE, Ie as BOUNCINESS_INDEX, Le as BOUNCINESS_SIZE, u as COLLIDABLE_QUERY, Sn as CollisionBroadphase, he as DEFAULT_COLLIDE_CATEGORY, ge as DEFAULT_COLLIDE_MASK, Jr as DEFAULT_PATH_SEARCH_ITERATION_BUDGET, d as DEFAULT_PHYSICS_STEP_MS, re as DYNAMICS_ACCELERATION_X_INDEX, ie as DYNAMICS_ACCELERATION_Y_INDEX, ae as DYNAMICS_INVERSE_MASS_INDEX, oe as DYNAMICS_SIZE, $ as FollowStep, Ar as GridAStar, Ze as INTERPOLATION_CHANNEL_INDEX, Ue as INTERPOLATION_DURATION_INDEX, et as INTERPOLATION_PREVIOUS_DURATION_INDEX, nt as INTERPOLATION_PREVIOUS_TICK_INDEX, tt as INTERPOLATION_PREVIOUS_TOTAL_DURATION_INDEX, Qe as INTERPOLATION_PREVIOUS_X_INDEX, $e as INTERPOLATION_PREVIOUS_Y_INDEX, qe as INTERPOLATION_REMAINING_DURATION_INDEX, rt as INTERPOLATION_SIZE, Ke as INTERPOLATION_SYNCED_DURATION_INDEX, Xe as INTERPOLATION_SYNCED_STEP_DURATION_INDEX, He as INTERPOLATION_SYNCED_TICK_INDEX, Je as INTERPOLATION_TARGET_X_INDEX, Ye as INTERPOLATION_TARGET_Y_INDEX, We as INTERPOLATION_TICK_INDEX, Ge as INTERPOLATION_TOTAL_DURATION_INDEX, Be as INTERPOLATION_X_INDEX, Ve as INTERPOLATION_Y_INDEX, ti as InterpolationSystem, b as MAX_POLYGON_VERTICES, vr as MinHeap, dt as NAVIGATION_ACTIVE_INDEX, ft as NAVIGATION_GOAL_X_INDEX, pt as NAVIGATION_GOAL_Y_INDEX, ht as NAVIGATION_MAX_WAYPOINTS, ct as NAVIGATION_OUTCOME_INDEX, ot as NAVIGATION_REQUEST_INDEX, st as NAVIGATION_RESULT_INDEX, gt as NAVIGATION_SIZE, mt as NAVIGATION_WAYPOINTS_INDEX, ut as NAVIGATION_WAYPOINT_COUNT_INDEX, lt as NAVIGATION_WAYPOINT_INDEX, _r as NavGrid, Fr as PATH_BLOCKERS_QUERY, Ir as PATH_GATES_QUERY, C as POLYGON_SIZE, x as POLYGON_VERTEX_COUNT_INDEX, S as POLYGON_VERTICES_INDEX, l as POSITION_UPDATED_EVENT, L as PathStatus, $r as PathfindingSystem, $t as PhysicalWorld, mr as PhysicsSystem, pe as SHAPE_CAPSULE, fe as SHAPE_CIRCLE, me as SHAPE_POLYGON, de as SHAPE_RECTANGLE, kn as SpatialIndex, v as TRANSFORM_ANGLE_INDEX, _ as TRANSFORM_HEIGHT_INDEX, y as TRANSFORM_SIZE, g as TRANSFORM_WIDTH_INDEX, m as TRANSFORM_X_INDEX, h as TRANSFORM_Y_INDEX, te as VELOCITY_DAMPING_INDEX, M as VELOCITY_SIZE, j as VELOCITY_X_INDEX, ee as VELOCITY_Y_INDEX, Mn as addPhysicalWorldData, Gr as applyPathBlockerChanges, Kr as applyPathGateChanges, zr as applyRectChanges, Rr as blockerRect, Ur as blockingRects, ke as blocksPath, Ne as bodyDefinition, F as bodyShape, ze as bouncinessDefinition, Gt as boundsHalfHeight, Wt as boundsHalfWidth, De as canCollide, V as capsuleCoreAngle, B as capsuleHalfLength, Lt as contactNormal, Vr as createNavigationState, Yr as createPathfindingUpdate, $n as createPhysicsUpdate, ce as dynamicsDefinition, Pr as followPath, An as getSpatialMap, Fn as integrateDynamics, at as interpolationDefinition, ei as interpolationUpdate, Oe as isContinuous, Ae as isDying, St as isNavigating, wt as isPathPending, I as isSensor, Tt as isUnreachable, je as markDying, yt as navigateTo, vt as navigationDefinition, Et as navigationGoal, Hr as navigationGridFor, Mt as navigationRegistry, Kt as orientedBoxesOverlap, Lr as pathBlockerQueries, Xr as pathfindingUpdate, jt as physicsRegistry, ar as physicsUpdate, K as pointSegmentDistanceSquared, rn as polygonContactNormal, T as polygonDefinition, nn as polygonShapesOverlap, E as preparePolygon, Ct as requestPath, Jt as segmentBoxDistanceSquared, qt as segmentSegmentDistanceSquared, jn as setEntityPosition, bt as setNavigationGoal, Wr as setNavigationTerrainSpeed, U as shapeHalfHeight, H as shapeHalfWidth, Pt as shapeIsEmpty, Nt as shapeRadius, Ft as shapesOverlap, xr as smoothPath, Nn as snapEntity, Pn as startSpawnInterpolation, xt as stopNavigating, yr as sweepCost, A as transformDefinition, Q as updateSpatialMap, N as velocityDefinition, Dt as waypoint, Ot as waypointX, kt as waypointY, At as writePath };
|
|
2280
2296
|
|
|
2281
2297
|
//# sourceMappingURL=index.js.map
|