@daneren2005/shared-memory-physics 1.9.1 → 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 +318 -305
- package/dist/index.js.map +1 -1
- package/dist/systems/physics-update.d.ts +2 -0
- package/dist/world.d.ts +4 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { loadFloat32 as i, storeFloat32 as a } from "@daneren2005/shared-memory-
|
|
|
3
3
|
import o from "@daneren2005/shared-memory-objects/spatial/shared-spatial-map";
|
|
4
4
|
import s from "flatbush";
|
|
5
5
|
import { addAtomicFloat32 as c } from "@daneren2005/shared-memory-objects/utils/atomic-math";
|
|
6
|
-
|
|
6
|
+
// src/constants.ts
|
|
7
7
|
var l = "position-updated", u = "collidable", d = 50, f = 1.5, p = .5, m = 0, h = 1, g = 2, _ = 3, v = 4, y = 5, b = 16, x = 0, S = 1, C = 33, w = class extends t {
|
|
8
8
|
get vertexCount() {
|
|
9
9
|
return this.block[0];
|
|
@@ -66,8 +66,7 @@ function D(e, t, n, r) {
|
|
|
66
66
|
function O(e, t, n) {
|
|
67
67
|
return (t[0] - e[0]) * (n[1] - e[1]) - (t[1] - e[1]) * (n[0] - e[0]);
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
//#region src/components/transform-component.ts
|
|
69
|
+
// src/components/transform-component.ts
|
|
71
70
|
var k = class extends t {
|
|
72
71
|
get x() {
|
|
73
72
|
return this.block[0];
|
|
@@ -137,7 +136,7 @@ var k = class extends t {
|
|
|
137
136
|
}, n = e.angle;
|
|
138
137
|
return n !== 0 && (t.angle = n), t;
|
|
139
138
|
}
|
|
140
|
-
}, j = 0, ee = 1, te = 2,
|
|
139
|
+
}, j = 0, ee = 1, te = 2, M = 3, ne = class extends t {
|
|
141
140
|
get velocityX() {
|
|
142
141
|
return this.block[0];
|
|
143
142
|
}
|
|
@@ -154,9 +153,9 @@ var k = class extends t {
|
|
|
154
153
|
return this.block[2];
|
|
155
154
|
}
|
|
156
155
|
set damping(e) {
|
|
157
|
-
|
|
156
|
+
P(e), this.block[2] = e;
|
|
158
157
|
}
|
|
159
|
-
},
|
|
158
|
+
}, N = {
|
|
160
159
|
type: Float32Array,
|
|
161
160
|
size: 3,
|
|
162
161
|
loadProperties: [
|
|
@@ -166,14 +165,14 @@ var k = class extends t {
|
|
|
166
165
|
],
|
|
167
166
|
toBlock(e) {
|
|
168
167
|
let t = e.damping ?? 0;
|
|
169
|
-
return
|
|
168
|
+
return P(t), [
|
|
170
169
|
e.velocityX ?? 0,
|
|
171
170
|
e.velocityY ?? 0,
|
|
172
171
|
t
|
|
173
172
|
];
|
|
174
173
|
},
|
|
175
174
|
attach(e, t, n) {
|
|
176
|
-
return new
|
|
175
|
+
return new ne(t.getBlock(n), n);
|
|
177
176
|
},
|
|
178
177
|
save(e) {
|
|
179
178
|
return {
|
|
@@ -183,31 +182,30 @@ var k = class extends t {
|
|
|
183
182
|
};
|
|
184
183
|
}
|
|
185
184
|
};
|
|
186
|
-
function
|
|
185
|
+
function P(e) {
|
|
187
186
|
if (!Number.isFinite(e) || e < 0) throw Error("Damping must be a finite number of at least zero");
|
|
188
187
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var ie = 0, ae = 1, oe = 2, se = 3, ce = class extends t {
|
|
188
|
+
// src/components/dynamics-component-constants.ts
|
|
189
|
+
var re = 0, ie = 1, ae = 2, oe = 3, se = class extends t {
|
|
192
190
|
get accelerationX() {
|
|
193
191
|
return this.block[0];
|
|
194
192
|
}
|
|
195
193
|
set accelerationX(e) {
|
|
196
|
-
|
|
194
|
+
ue(e, "Acceleration"), this.block[0] = e;
|
|
197
195
|
}
|
|
198
196
|
get accelerationY() {
|
|
199
197
|
return this.block[1];
|
|
200
198
|
}
|
|
201
199
|
set accelerationY(e) {
|
|
202
|
-
|
|
200
|
+
ue(e, "Acceleration"), this.block[1] = e;
|
|
203
201
|
}
|
|
204
202
|
get mass() {
|
|
205
203
|
return 1 / this.block[2];
|
|
206
204
|
}
|
|
207
205
|
set mass(e) {
|
|
208
|
-
|
|
206
|
+
le(e), this.block[2] = 1 / e;
|
|
209
207
|
}
|
|
210
|
-
},
|
|
208
|
+
}, ce = {
|
|
211
209
|
type: Float32Array,
|
|
212
210
|
size: 3,
|
|
213
211
|
loadProperties: [
|
|
@@ -217,14 +215,14 @@ var ie = 0, ae = 1, oe = 2, se = 3, ce = class extends t {
|
|
|
217
215
|
],
|
|
218
216
|
toBlock(e) {
|
|
219
217
|
let t = e.accelerationX ?? 0, n = e.accelerationY ?? 0, r = e.mass ?? 1;
|
|
220
|
-
return
|
|
218
|
+
return ue(t, "Acceleration"), ue(n, "Acceleration"), le(r), [
|
|
221
219
|
t,
|
|
222
220
|
n,
|
|
223
221
|
1 / r
|
|
224
222
|
];
|
|
225
223
|
},
|
|
226
224
|
attach(e, t, n) {
|
|
227
|
-
return new
|
|
225
|
+
return new se(t.getBlock(n), n);
|
|
228
226
|
},
|
|
229
227
|
save(e) {
|
|
230
228
|
return {
|
|
@@ -234,42 +232,41 @@ var ie = 0, ae = 1, oe = 2, se = 3, ce = class extends t {
|
|
|
234
232
|
};
|
|
235
233
|
}
|
|
236
234
|
};
|
|
237
|
-
function
|
|
235
|
+
function le(e) {
|
|
238
236
|
if (!Number.isFinite(e) || e <= 0) throw Error("Mass must be a finite number greater than zero");
|
|
239
237
|
}
|
|
240
|
-
function
|
|
238
|
+
function ue(e, t) {
|
|
241
239
|
if (!Number.isFinite(e)) throw Error(`${t} must be a finite number`);
|
|
242
240
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
var fe = 1, pe = 2, me = 3, he = 4, ge = 1, _e = 4294967295, ve = 0, ye = 1, be = 2, xe = 3, Se = 7, Ce = 8, we = 16, Te = 32, Ee = 64, De = [
|
|
241
|
+
// src/components/body-component-constants.ts
|
|
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 = [
|
|
246
243
|
1,
|
|
247
244
|
2,
|
|
248
245
|
3,
|
|
249
246
|
4
|
|
250
247
|
];
|
|
251
|
-
function
|
|
248
|
+
function De(e, t, n, r) {
|
|
252
249
|
return (t & n) !== 0 && (r & e) !== 0;
|
|
253
250
|
}
|
|
254
|
-
function
|
|
251
|
+
function F(e) {
|
|
255
252
|
return e[0] & 7;
|
|
256
253
|
}
|
|
257
|
-
function
|
|
254
|
+
function I(e) {
|
|
258
255
|
return !!(e[0] & 8);
|
|
259
256
|
}
|
|
260
|
-
function
|
|
257
|
+
function Oe(e) {
|
|
261
258
|
return !!(e[0] & 16);
|
|
262
259
|
}
|
|
263
|
-
function
|
|
260
|
+
function ke(e) {
|
|
264
261
|
return !!(e[0] & 64);
|
|
265
262
|
}
|
|
266
|
-
function
|
|
263
|
+
function Ae(e) {
|
|
267
264
|
return !!(e[0] & 32);
|
|
268
265
|
}
|
|
269
|
-
function
|
|
266
|
+
function je(e) {
|
|
270
267
|
e[0] |= 32;
|
|
271
268
|
}
|
|
272
|
-
var
|
|
269
|
+
var Me = class extends t {
|
|
273
270
|
get shape() {
|
|
274
271
|
return this.block[0] & 7;
|
|
275
272
|
}
|
|
@@ -306,7 +303,7 @@ var Ne = class extends t {
|
|
|
306
303
|
set blocksPath(e) {
|
|
307
304
|
this.block[0] = e ? this.block[0] | 64 : this.block[0] & -65;
|
|
308
305
|
}
|
|
309
|
-
},
|
|
306
|
+
}, Ne = {
|
|
310
307
|
type: Uint32Array,
|
|
311
308
|
size: 3,
|
|
312
309
|
loadProperties: [
|
|
@@ -323,36 +320,35 @@ var Ne = class extends t {
|
|
|
323
320
|
],
|
|
324
321
|
toBlock(e) {
|
|
325
322
|
return [
|
|
326
|
-
|
|
323
|
+
Pe(e),
|
|
327
324
|
e.collideCategory ?? 1,
|
|
328
325
|
e.collideMask ?? 4294967295
|
|
329
326
|
];
|
|
330
327
|
},
|
|
331
328
|
attach(e, t, n) {
|
|
332
|
-
return new
|
|
329
|
+
return new Me(t.getBlock(n), n);
|
|
333
330
|
}
|
|
334
331
|
};
|
|
335
|
-
function
|
|
336
|
-
let t =
|
|
332
|
+
function Pe(e) {
|
|
333
|
+
let t = Fe(e);
|
|
337
334
|
return e.sensor && (t |= 8), e.continuousCollisionDetection && (t |= 16), e.blocksPath && (t |= 64), t;
|
|
338
335
|
}
|
|
339
|
-
function
|
|
336
|
+
function Fe(e) {
|
|
340
337
|
let t = e.shape;
|
|
341
338
|
if (t === void 0) return e.vertices === void 0 ? e.radius === void 0 ? 1 : 2 : 4;
|
|
342
|
-
if (!
|
|
339
|
+
if (!Ee.includes(t)) throw Error(`Unknown body shape: ${t}`);
|
|
343
340
|
if (t === 4 && e.vertices === void 0) throw Error("A polygon body requires vertices");
|
|
344
341
|
return t;
|
|
345
342
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
var Le = 0, Re = 1, ze = class extends t {
|
|
343
|
+
// src/components/bounciness-component-constants.ts
|
|
344
|
+
var Ie = 0, Le = 1, Re = class extends t {
|
|
349
345
|
get bounciness() {
|
|
350
346
|
return this.block[0];
|
|
351
347
|
}
|
|
352
348
|
set bounciness(e) {
|
|
353
349
|
this.block[0] = e;
|
|
354
350
|
}
|
|
355
|
-
},
|
|
351
|
+
}, ze = {
|
|
356
352
|
type: Float32Array,
|
|
357
353
|
size: 1,
|
|
358
354
|
loadProperties: ["bounciness"],
|
|
@@ -360,9 +356,9 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
360
356
|
return [e.bounciness ?? 0];
|
|
361
357
|
},
|
|
362
358
|
attach(e, t, n) {
|
|
363
|
-
return new
|
|
359
|
+
return new Re(t.getBlock(n), n);
|
|
364
360
|
}
|
|
365
|
-
},
|
|
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 {
|
|
366
362
|
get x() {
|
|
367
363
|
return this.block[0];
|
|
368
364
|
}
|
|
@@ -441,7 +437,7 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
441
437
|
set remainingDuration(e) {
|
|
442
438
|
this.block[7] = e;
|
|
443
439
|
}
|
|
444
|
-
},
|
|
440
|
+
}, at = {
|
|
445
441
|
type: Float32Array,
|
|
446
442
|
size: 17,
|
|
447
443
|
loadProperties: ["interpolate"],
|
|
@@ -468,13 +464,13 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
468
464
|
];
|
|
469
465
|
},
|
|
470
466
|
attach(e, t, n) {
|
|
471
|
-
return new
|
|
467
|
+
return new it(t.getBlock(n), n);
|
|
472
468
|
}
|
|
473
|
-
},
|
|
469
|
+
}, ot = 0, st = 1, ct = 2, lt = 3, ut = 4, dt = 5, ft = 6, pt = 7, mt = 8, ht = 32, gt = 72, L = {
|
|
474
470
|
Found: 1,
|
|
475
471
|
Incomplete: 2,
|
|
476
472
|
Unreachable: 3
|
|
477
|
-
},
|
|
473
|
+
}, _t = class extends t {
|
|
478
474
|
get active() {
|
|
479
475
|
return this.block[5] !== 0;
|
|
480
476
|
}
|
|
@@ -485,7 +481,7 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
485
481
|
return i(this.block, 7);
|
|
486
482
|
}
|
|
487
483
|
get pending() {
|
|
488
|
-
return
|
|
484
|
+
return wt(this.block);
|
|
489
485
|
}
|
|
490
486
|
get outcome() {
|
|
491
487
|
return this.block[2];
|
|
@@ -494,57 +490,57 @@ var Le = 0, Re = 1, ze = class extends t {
|
|
|
494
490
|
return this.block[3];
|
|
495
491
|
}
|
|
496
492
|
get waypoints() {
|
|
497
|
-
return Array.from({ length: this.block[4] }, (e, t) =>
|
|
493
|
+
return Array.from({ length: this.block[4] }, (e, t) => Dt(this.block, t));
|
|
498
494
|
}
|
|
499
495
|
navigateTo(e, t) {
|
|
500
|
-
|
|
496
|
+
yt(this.block, e, t);
|
|
501
497
|
}
|
|
502
498
|
stop() {
|
|
503
|
-
|
|
499
|
+
xt(this.block);
|
|
504
500
|
}
|
|
505
|
-
},
|
|
501
|
+
}, vt = {
|
|
506
502
|
type: Int32Array,
|
|
507
503
|
size: 72,
|
|
508
504
|
loadProperties: ["navigate"],
|
|
509
505
|
toBlock: () => Array.from({ length: 72 }, () => 0),
|
|
510
506
|
attach(e, t, n) {
|
|
511
|
-
return new
|
|
507
|
+
return new _t(t.getBlock(n), n);
|
|
512
508
|
}
|
|
513
509
|
};
|
|
514
|
-
function
|
|
515
|
-
|
|
510
|
+
function yt(e, t, n) {
|
|
511
|
+
bt(e, t, n), e[5] = 1, Ct(e);
|
|
516
512
|
}
|
|
517
|
-
function
|
|
513
|
+
function bt(e, t, n) {
|
|
518
514
|
a(e, 6, t), a(e, 7, n);
|
|
519
515
|
}
|
|
520
|
-
function
|
|
516
|
+
function xt(e) {
|
|
521
517
|
e[5] = 0;
|
|
522
518
|
}
|
|
523
|
-
function
|
|
519
|
+
function St(e) {
|
|
524
520
|
return e[5] !== 0;
|
|
525
521
|
}
|
|
526
|
-
function
|
|
522
|
+
function Ct(e) {
|
|
527
523
|
Atomics.add(e, 0, 1);
|
|
528
524
|
}
|
|
529
|
-
function
|
|
525
|
+
function wt(e) {
|
|
530
526
|
return Atomics.load(e, 0) !== Atomics.load(e, 1);
|
|
531
527
|
}
|
|
532
|
-
function
|
|
533
|
-
return !
|
|
528
|
+
function Tt(e) {
|
|
529
|
+
return !wt(e) && e[2] === L.Unreachable;
|
|
534
530
|
}
|
|
535
|
-
function
|
|
531
|
+
function Et(e) {
|
|
536
532
|
return {
|
|
537
533
|
x: i(e, 6),
|
|
538
534
|
y: i(e, 7)
|
|
539
535
|
};
|
|
540
536
|
}
|
|
541
|
-
function
|
|
537
|
+
function Dt(e, t) {
|
|
542
538
|
return {
|
|
543
|
-
x:
|
|
539
|
+
x: Ot(e, t),
|
|
544
540
|
y: kt(e, t)
|
|
545
541
|
};
|
|
546
542
|
}
|
|
547
|
-
function
|
|
543
|
+
function Ot(e, t) {
|
|
548
544
|
return i(e, 8 + t * 2);
|
|
549
545
|
}
|
|
550
546
|
function kt(e, t) {
|
|
@@ -553,19 +549,18 @@ function kt(e, t) {
|
|
|
553
549
|
function At(e, t, n) {
|
|
554
550
|
let r = n.length > 32, i = r ? 32 : n.length;
|
|
555
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);
|
|
556
|
-
e[4] = i, e[3] = 0, e[2] = r ?
|
|
552
|
+
e[4] = i, e[3] = 0, e[2] = r ? L.Incomplete : t;
|
|
557
553
|
}
|
|
558
|
-
|
|
559
|
-
//#region src/components/registry.ts
|
|
554
|
+
// src/components/registry.ts
|
|
560
555
|
var jt = {
|
|
561
556
|
transform: A,
|
|
562
|
-
velocity:
|
|
563
|
-
body:
|
|
557
|
+
velocity: N,
|
|
558
|
+
body: Ne,
|
|
564
559
|
polygon: T,
|
|
565
|
-
bounciness:
|
|
566
|
-
dynamics:
|
|
567
|
-
interpolation:
|
|
568
|
-
}, Mt = { navigation:
|
|
560
|
+
bounciness: ze,
|
|
561
|
+
dynamics: ce,
|
|
562
|
+
interpolation: at
|
|
563
|
+
}, Mt = { navigation: vt }, R = {
|
|
569
564
|
x: 0,
|
|
570
565
|
y: 0
|
|
571
566
|
}, z = {
|
|
@@ -694,10 +689,9 @@ function Xt(e, t, n, r, i) {
|
|
|
694
689
|
function q(e) {
|
|
695
690
|
return e < 0 ? 0 : e > 1 ? 1 : e;
|
|
696
691
|
}
|
|
697
|
-
|
|
698
|
-
//#region src/systems/spatial-bounds.ts
|
|
692
|
+
// src/systems/spatial-bounds.ts
|
|
699
693
|
function J(e) {
|
|
700
|
-
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];
|
|
701
695
|
return {
|
|
702
696
|
minX: c - o,
|
|
703
697
|
minY: l - s,
|
|
@@ -711,11 +705,11 @@ function Zt(e, t, n, r, i) {
|
|
|
711
705
|
function Qt(e, t) {
|
|
712
706
|
return t > e ? t - e : Math.max(1, Math.abs(e)) * 2 ** -52;
|
|
713
707
|
}
|
|
714
|
-
|
|
715
|
-
//#region src/world.ts
|
|
708
|
+
// src/world.ts
|
|
716
709
|
var $t = class extends e {
|
|
717
710
|
spatialMap;
|
|
718
711
|
spatialIds = /* @__PURE__ */ new Set();
|
|
712
|
+
pendingSpatial = /* @__PURE__ */ new Map();
|
|
719
713
|
constructor(e, t = {}) {
|
|
720
714
|
let { spatial: n, ...r } = t;
|
|
721
715
|
super(e, r), this.spatialMap = new o(this.heap, {
|
|
@@ -728,12 +722,25 @@ var $t = class extends e {
|
|
|
728
722
|
(t === "transform" || t === "body") && this.updateSpatialEntity(e);
|
|
729
723
|
});
|
|
730
724
|
}), this.on("entity-removed", (e) => {
|
|
731
|
-
this.spatialIds.delete(e.eid), this.spatialMap.remove(e.eid);
|
|
725
|
+
this.pendingSpatial.delete(e.eid), this.spatialIds.delete(e.eid), this.spatialMap.remove(e.eid);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
load(e, t = {}) {
|
|
729
|
+
return this.pendingSpatial.clear(), super.load(e, {
|
|
730
|
+
...t,
|
|
731
|
+
onEntitiesReady: () => {
|
|
732
|
+
this.flushPendingSpatial(), t.onEntitiesReady?.();
|
|
733
|
+
}
|
|
732
734
|
});
|
|
733
735
|
}
|
|
734
736
|
updateSpatialEntity(e) {
|
|
735
737
|
let t = typeof e == "number" ? this.getEntityByEid(e) : e;
|
|
736
738
|
if (!t) return;
|
|
739
|
+
if (this.isBulkLoading) {
|
|
740
|
+
this.pendingSpatial.set(t.eid, t);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
this.flushPendingSpatial();
|
|
737
744
|
let n = t.components, r = n.transform?.block;
|
|
738
745
|
if (!r) {
|
|
739
746
|
this.spatialIds.delete(t.eid), this.spatialMap.remove(t.eid);
|
|
@@ -745,8 +752,32 @@ var $t = class extends e {
|
|
|
745
752
|
});
|
|
746
753
|
this.spatialIds.add(t.eid), this.spatialMap.update(t.eid, i.minX, i.minY, i.maxX - i.minX, i.maxY - i.minY);
|
|
747
754
|
}
|
|
755
|
+
flushPendingSpatial() {
|
|
756
|
+
if (this.pendingSpatial.size === 0) return;
|
|
757
|
+
let e = [];
|
|
758
|
+
for (let t of this.pendingSpatial.values()) {
|
|
759
|
+
let n = t.components, r = n.transform?.block;
|
|
760
|
+
if (!r) {
|
|
761
|
+
this.spatialIds.delete(t.eid), this.spatialMap.remove(t.eid);
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
let i = J({
|
|
765
|
+
transform: r,
|
|
766
|
+
body: n.body?.block
|
|
767
|
+
});
|
|
768
|
+
this.spatialIds.add(t.eid), e.push({
|
|
769
|
+
id: t.eid,
|
|
770
|
+
x: i.minX,
|
|
771
|
+
y: i.minY,
|
|
772
|
+
width: i.maxX - i.minX,
|
|
773
|
+
height: i.maxY - i.minY
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
this.pendingSpatial.clear(), this.spatialMap.bulkInsert(e);
|
|
777
|
+
}
|
|
748
778
|
searchSpatial(e, t, n, r, i) {
|
|
749
779
|
if (n < e || r < t) return [];
|
|
780
|
+
this.flushPendingSpatial();
|
|
750
781
|
let a = [], o = Number.isFinite(e) && Number.isFinite(t) && Number.isFinite(n) && Number.isFinite(r) ? this.spatialMap.search(e, t, Qt(e, n), Qt(t, r)) : this.spatialIds;
|
|
751
782
|
for (let s of o) {
|
|
752
783
|
let o = this.getEntityByEid(s);
|
|
@@ -766,7 +797,7 @@ var $t = class extends e {
|
|
|
766
797
|
return this.findNearbySpatial(e, t, 1, n, r)[0];
|
|
767
798
|
}
|
|
768
799
|
findNearbySpatial(e, t, n, r = Infinity, i) {
|
|
769
|
-
return this.spatialMap.neighbors(e, t, n, r, (e) => {
|
|
800
|
+
return this.flushPendingSpatial(), this.spatialMap.neighbors(e, t, n, r, (e) => {
|
|
770
801
|
let t = this.getEntityByEid(e);
|
|
771
802
|
return !!t && (!i || i(t));
|
|
772
803
|
}).flatMap((e) => {
|
|
@@ -808,9 +839,9 @@ function sn(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
|
|
|
808
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);
|
|
809
840
|
}
|
|
810
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) {
|
|
811
|
-
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,
|
|
812
|
-
for (let e = 0; e <
|
|
813
|
-
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;
|
|
814
845
|
if (!ln(t - i, n - a, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E)) return !1;
|
|
815
846
|
}
|
|
816
847
|
return !0;
|
|
@@ -870,8 +901,7 @@ function pn(e, t, n, r, i, a) {
|
|
|
870
901
|
function mn(e) {
|
|
871
902
|
return e === 2 || e === 3;
|
|
872
903
|
}
|
|
873
|
-
|
|
874
|
-
//#region src/actions/dynamics-commands.ts
|
|
904
|
+
// src/actions/dynamics-commands.ts
|
|
875
905
|
function hn() {
|
|
876
906
|
return {
|
|
877
907
|
forceX: 0,
|
|
@@ -880,8 +910,7 @@ function hn() {
|
|
|
880
910
|
impulseY: 0
|
|
881
911
|
};
|
|
882
912
|
}
|
|
883
|
-
|
|
884
|
-
//#region src/actions/find-dynamics-command.ts
|
|
913
|
+
// src/actions/find-dynamics-command.ts
|
|
885
914
|
function gn(e, t) {
|
|
886
915
|
if (!e) return;
|
|
887
916
|
let n = 0, r = e.length - 1;
|
|
@@ -891,8 +920,7 @@ function gn(e, t) {
|
|
|
891
920
|
a.entityId < t ? n = i + 1 : r = i - 1;
|
|
892
921
|
}
|
|
893
922
|
}
|
|
894
|
-
|
|
895
|
-
//#region src/actions/find-dynamics-command-offset.ts
|
|
923
|
+
// src/actions/find-dynamics-command-offset.ts
|
|
896
924
|
function _n(e, t) {
|
|
897
925
|
let n = 0, r = e.length / 8 - 1;
|
|
898
926
|
for (; n <= r;) {
|
|
@@ -902,8 +930,7 @@ function _n(e, t) {
|
|
|
902
930
|
}
|
|
903
931
|
return -1;
|
|
904
932
|
}
|
|
905
|
-
|
|
906
|
-
//#region src/systems/collision.ts
|
|
933
|
+
// src/systems/collision.ts
|
|
907
934
|
var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
908
935
|
fraction: 1,
|
|
909
936
|
blocking: X
|
|
@@ -918,18 +945,18 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
918
945
|
if (!o || !s) continue;
|
|
919
946
|
let c = s[1];
|
|
920
947
|
if (c === 0) continue;
|
|
921
|
-
let l =
|
|
948
|
+
let l = F(s), u = o[2], d = o[3];
|
|
922
949
|
if (Pt(l, u, d)) continue;
|
|
923
950
|
let f = o[4], p = H(l, u, d, f), m = U(l, u, d, f);
|
|
924
951
|
e.bounciness && (this.hasBounciness = !0);
|
|
925
|
-
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,
|
|
926
|
-
|
|
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 = {
|
|
927
954
|
entries: [],
|
|
928
955
|
bounds: []
|
|
929
|
-
}, r.set(c,
|
|
956
|
+
}, r.set(c, P)), P.entries.push({
|
|
930
957
|
entityId: n.entityId,
|
|
931
958
|
components: e
|
|
932
|
-
}),
|
|
959
|
+
}), P.bounds.push(ne - p - te, N - m - M, ne + p + te, N + m + M);
|
|
933
960
|
}
|
|
934
961
|
for (let [e, { entries: t, bounds: n }] of r) {
|
|
935
962
|
let r = new s(t.length);
|
|
@@ -954,9 +981,7 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
954
981
|
this.forEachCandidate(i, u, d, f, p, (a) => {
|
|
955
982
|
En(i, e, l, n, r, a) && t(a);
|
|
956
983
|
});
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
this.forEachCandidate(i, a - s, o - c, a + s, o + c, (e) => {
|
|
984
|
+
} else this.forEachCandidate(i, a - s, o - c, a + s, o + c, (e) => {
|
|
960
985
|
Z(i, a, o, e) && t(e);
|
|
961
986
|
});
|
|
962
987
|
}
|
|
@@ -1057,7 +1082,7 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
1057
1082
|
if (e.sensor) return [];
|
|
1058
1083
|
let s = r + t, c = i + n, l = [];
|
|
1059
1084
|
return this.forEachCandidate(e, s - a, c - o, s + a, c + o, (t) => {
|
|
1060
|
-
Z(e, s, c, t) && (
|
|
1085
|
+
Z(e, s, c, t) && (I(t.components.body) || Z(e, r, i, t) || l.push(t));
|
|
1061
1086
|
}), l;
|
|
1062
1087
|
}
|
|
1063
1088
|
refine(e, t, n, r, i) {
|
|
@@ -1077,7 +1102,7 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
1077
1102
|
if (e.sensor) return [];
|
|
1078
1103
|
let { x: r, y: i, halfWidth: a, halfHeight: o } = e, s = r + t, c = i + n, l = [];
|
|
1079
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) => {
|
|
1080
|
-
|
|
1105
|
+
I(a.components.body) || Z(e, r, i, a) || En(e, r, i, t, n, a) && l.push(a);
|
|
1081
1106
|
}), l;
|
|
1082
1107
|
}
|
|
1083
1108
|
sweepContinuous(e, t, n, r) {
|
|
@@ -1122,12 +1147,12 @@ var vn = 1e-4, yn = 24, X = [], bn = 2 ** 26, xn = {
|
|
|
1122
1147
|
forEachCandidate(e, t, r, i, a, o) {
|
|
1123
1148
|
for (let s of this.buckets) if ((e.mask & s.category) !== 0) for (let c of s.index.search(t, r, i, a)) {
|
|
1124
1149
|
let t = s.entries[c];
|
|
1125
|
-
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));
|
|
1126
1151
|
}
|
|
1127
1152
|
}
|
|
1128
1153
|
};
|
|
1129
1154
|
function Cn(e, t, n, r, i) {
|
|
1130
|
-
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];
|
|
1131
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);
|
|
1132
1157
|
}
|
|
1133
1158
|
function wn(e, t) {
|
|
@@ -1142,7 +1167,7 @@ function Tn(e) {
|
|
|
1142
1167
|
if (!t) return;
|
|
1143
1168
|
let n = t[2];
|
|
1144
1169
|
if (n === 0) return;
|
|
1145
|
-
let r = e.components.transform, i =
|
|
1170
|
+
let r = e.components.transform, i = F(t), a = r[2], o = r[3];
|
|
1146
1171
|
if (Pt(i, a, o)) return;
|
|
1147
1172
|
let s = r[4], c = e.components.polygon;
|
|
1148
1173
|
if (i !== 4 || c) return {
|
|
@@ -1158,12 +1183,12 @@ function Tn(e) {
|
|
|
1158
1183
|
halfHeight: U(i, a, o, s),
|
|
1159
1184
|
category: t[1],
|
|
1160
1185
|
mask: n,
|
|
1161
|
-
sensor:
|
|
1162
|
-
ccd:
|
|
1186
|
+
sensor: I(t),
|
|
1187
|
+
ccd: Oe(t)
|
|
1163
1188
|
};
|
|
1164
1189
|
}
|
|
1165
1190
|
function En(e, t, n, r, i, a) {
|
|
1166
|
-
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];
|
|
1167
1192
|
if (e.shape === 1 || e.shape === 4) {
|
|
1168
1193
|
let c = Math.cos(e.angle), h = Math.sin(e.angle), g = r * c + i * h, _ = -r * h + i * c;
|
|
1169
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);
|
|
@@ -1176,13 +1201,12 @@ function Dn(e) {
|
|
|
1176
1201
|
}
|
|
1177
1202
|
function Z(e, t, n, r) {
|
|
1178
1203
|
let i = r.components.transform;
|
|
1179
|
-
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]);
|
|
1180
1205
|
}
|
|
1181
1206
|
function On(e, t, n, r, i, a, o, s, c, l, u, d, f, p) {
|
|
1182
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);
|
|
1183
1208
|
}
|
|
1184
|
-
|
|
1185
|
-
//#region src/systems/spatial-index.ts
|
|
1209
|
+
// src/systems/spatial-index.ts
|
|
1186
1210
|
var kn = class {
|
|
1187
1211
|
entries = [];
|
|
1188
1212
|
index;
|
|
@@ -1191,7 +1215,7 @@ var kn = class {
|
|
|
1191
1215
|
for (let n of e) {
|
|
1192
1216
|
let e = n.components, r = e.transform;
|
|
1193
1217
|
if (!r) continue;
|
|
1194
|
-
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);
|
|
1195
1219
|
this.entries.push({
|
|
1196
1220
|
entityId: n.entityId,
|
|
1197
1221
|
components: e
|
|
@@ -1224,22 +1248,19 @@ var kn = class {
|
|
|
1224
1248
|
return (i ? a.neighbors(e, t, n, r, (e) => i(o[e])) : a.neighbors(e, t, n, r)).map((e) => o[e]);
|
|
1225
1249
|
}
|
|
1226
1250
|
};
|
|
1227
|
-
|
|
1228
|
-
//#region src/actions/get-spatial-map.ts
|
|
1251
|
+
// src/actions/get-spatial-map.ts
|
|
1229
1252
|
function An(e) {
|
|
1230
1253
|
if (e.spatialMap) return e.spatialMap;
|
|
1231
1254
|
if (!e.heap || !e.spatialMapMemory) throw Error("Spatial system world is missing its shared MemoryHeap or spatial map");
|
|
1232
1255
|
return e.spatialMap = new o(e.heap, e.spatialMapMemory), e.spatialMap;
|
|
1233
1256
|
}
|
|
1234
|
-
|
|
1235
|
-
//#region src/actions/update-spatial-map.ts
|
|
1257
|
+
// src/actions/update-spatial-map.ts
|
|
1236
1258
|
function Q(e, t, n) {
|
|
1237
1259
|
if (!e.spatialMap && (!e.heap || !e.spatialMapMemory)) return;
|
|
1238
1260
|
let r = An(e), i = J(n);
|
|
1239
1261
|
r.update(t, i.minX, i.minY, i.maxX - i.minX, i.maxY - i.minY);
|
|
1240
1262
|
}
|
|
1241
|
-
|
|
1242
|
-
//#region src/actions/set-entity-position.ts
|
|
1263
|
+
// src/actions/set-entity-position.ts
|
|
1243
1264
|
function jn(e, t, n) {
|
|
1244
1265
|
let r = t.components.transform;
|
|
1245
1266
|
if (!(r instanceof Float32Array)) return;
|
|
@@ -1250,35 +1271,30 @@ function jn(e, t, n) {
|
|
|
1250
1271
|
...i instanceof Uint32Array ? { body: i } : {}
|
|
1251
1272
|
});
|
|
1252
1273
|
}
|
|
1253
|
-
|
|
1254
|
-
//#region src/actions/add-physical-world-data.ts
|
|
1274
|
+
// src/actions/add-physical-world-data.ts
|
|
1255
1275
|
function Mn(e, t) {
|
|
1256
1276
|
t.spatialMapMemory = e.spatialMap.getSharedMemory();
|
|
1257
1277
|
}
|
|
1258
|
-
|
|
1259
|
-
//#region src/actions/snap-entity.ts
|
|
1278
|
+
// src/actions/snap-entity.ts
|
|
1260
1279
|
function Nn(e) {
|
|
1261
1280
|
let { transform: t, interpolation: n } = e.components;
|
|
1262
1281
|
t && n && (n.targetX = n.x = t.x, n.targetY = n.y = t.y, n.previousX = t.x, n.previousY = t.y, n.remainingDuration = 0, n.syncedStepDuration = 0, n.syncedDuration = n.totalDuration);
|
|
1263
1282
|
}
|
|
1264
|
-
|
|
1265
|
-
//#region src/actions/start-spawn-interpolation.ts
|
|
1283
|
+
// src/actions/start-spawn-interpolation.ts
|
|
1266
1284
|
function Pn(e, t) {
|
|
1267
1285
|
let { transform: n, velocity: r, interpolation: i } = e.components;
|
|
1268
1286
|
if (!n || !r || !i) return;
|
|
1269
1287
|
let a = 1 - (t.stepFraction < 0 ? 0 : t.stepFraction > 1 ? 1 : t.stepFraction), o = t.stepMs / 1e3, s = n.x, c = n.y, l = r.velocityX * o * a, u = r.velocityY * o * a;
|
|
1270
1288
|
n.x = s + l, n.y = c + u, i.x = s, i.y = c, i.duration = t.stepMs * a, i.syncedTick = t.tick, i.totalDuration += i.duration, i.syncedDuration = i.totalDuration, i.remainingDuration = i.duration, i.targetX = n.x, i.targetY = n.y, i.syncedStepDuration = i.duration, i.tick = t.tick;
|
|
1271
1289
|
}
|
|
1272
|
-
|
|
1273
|
-
//#region src/actions/integrate-dynamics.ts
|
|
1290
|
+
// src/actions/integrate-dynamics.ts
|
|
1274
1291
|
function Fn(e, t, n, r) {
|
|
1275
1292
|
let i = e.dynamicsCommands, a = i instanceof Float64Array ? i : void 0, o = gn(i && !(i instanceof Float64Array) ? i : void 0, t), s = a ? _n(a, t) : -1, c = n[2];
|
|
1276
1293
|
if (!r && !o && s < 0 && c === 0) return;
|
|
1277
1294
|
let l = e.elapsedTime / 1e3, u = r?.[2] ?? 1, d = s < 0 ? o?.forceX ?? 0 : a[s + 1], f = s < 0 ? o?.forceY ?? 0 : a[s + 2], p = s < 0 ? o?.impulseX ?? 0 : a[s + 3], m = s < 0 ? o?.impulseY ?? 0 : a[s + 4], h = s < 0 ? 0 : a[s + 5], g = s < 0 ? o?.velocityX : h & 1 ? a[s + 6] : void 0, _ = s < 0 ? o?.velocityY : h & 2 ? a[s + 7] : void 0, v = c > 0 ? 1 / (1 + c * l) : 1, y = (n[0] + (r?.[0] ?? 0) * l + d * u * l + p * u) * v, b = (n[1] + (r?.[1] ?? 0) * l + f * u * l + m * u) * v;
|
|
1278
1295
|
n[0] = g ?? y, n[1] = _ ?? b;
|
|
1279
1296
|
}
|
|
1280
|
-
|
|
1281
|
-
//#region src/systems/bounce.ts
|
|
1297
|
+
// src/systems/bounce.ts
|
|
1282
1298
|
var In = {
|
|
1283
1299
|
x: 0,
|
|
1284
1300
|
y: 0
|
|
@@ -1315,13 +1331,12 @@ function Hn(e, t, n) {
|
|
|
1315
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);
|
|
1316
1332
|
}
|
|
1317
1333
|
function Un(e) {
|
|
1318
|
-
return e ?
|
|
1334
|
+
return e ? F(e) : 1;
|
|
1319
1335
|
}
|
|
1320
1336
|
function Wn(e) {
|
|
1321
|
-
return e !== void 0 &&
|
|
1337
|
+
return e !== void 0 && I(e);
|
|
1322
1338
|
}
|
|
1323
|
-
|
|
1324
|
-
//#region src/actions/combine-dynamics-commands.ts
|
|
1339
|
+
// src/actions/combine-dynamics-commands.ts
|
|
1325
1340
|
function Gn(e, t) {
|
|
1326
1341
|
if (e.size === 0) return t;
|
|
1327
1342
|
let n = /* @__PURE__ */ new Map();
|
|
@@ -1343,11 +1358,7 @@ function Gn(e, t) {
|
|
|
1343
1358
|
}
|
|
1344
1359
|
function Kn(e, t) {
|
|
1345
1360
|
if (e) {
|
|
1346
|
-
if (
|
|
1347
|
-
for (let { entityId: n, ...r } of e) t(n, r);
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
for (let n = 0; n < e.length; n += 8) {
|
|
1361
|
+
if (e instanceof Float64Array) for (let n = 0; n < e.length; n += 8) {
|
|
1351
1362
|
let r = e[n + 5];
|
|
1352
1363
|
t(e[n + 0], {
|
|
1353
1364
|
forceX: e[n + 1],
|
|
@@ -1358,10 +1369,10 @@ function Kn(e, t) {
|
|
|
1358
1369
|
velocityY: r & 2 ? e[n + 7] : void 0
|
|
1359
1370
|
});
|
|
1360
1371
|
}
|
|
1372
|
+
else for (let { entityId: n, ...r } of e) t(n, r);
|
|
1361
1373
|
}
|
|
1362
1374
|
}
|
|
1363
|
-
|
|
1364
|
-
//#region src/actions/queue-dynamics-vector.ts
|
|
1375
|
+
// src/actions/queue-dynamics-vector.ts
|
|
1365
1376
|
function qn(e, t, n, r, i, a) {
|
|
1366
1377
|
if (Jn(n, r, "Force"), Jn(i, a, "Impulse"), n === 0 && r === 0 && i === 0 && a === 0) return;
|
|
1367
1378
|
let o = e.get(t) ?? hn(), s = {
|
|
@@ -1376,8 +1387,7 @@ function qn(e, t, n, r, i, a) {
|
|
|
1376
1387
|
function Jn(e, t, n) {
|
|
1377
1388
|
if (!Number.isFinite(e) || !Number.isFinite(t)) throw Error(`${n} must contain finite numbers`);
|
|
1378
1389
|
}
|
|
1379
|
-
|
|
1380
|
-
//#region src/actions/queue-velocity-assignment.ts
|
|
1390
|
+
// src/actions/queue-velocity-assignment.ts
|
|
1381
1391
|
function Yn(e, t, n) {
|
|
1382
1392
|
Xn(n), (n.velocityX !== void 0 || n.velocityY !== void 0) && e.set(t, {
|
|
1383
1393
|
...e.get(t) ?? hn(),
|
|
@@ -1387,20 +1397,23 @@ function Yn(e, t, n) {
|
|
|
1387
1397
|
function Xn(e) {
|
|
1388
1398
|
if (e.velocityX !== void 0 && !Number.isFinite(e.velocityX) || e.velocityY !== void 0 && !Number.isFinite(e.velocityY)) throw Error("Velocity assignment must contain finite numbers");
|
|
1389
1399
|
}
|
|
1390
|
-
|
|
1391
|
-
//#region src/systems/physics-update.ts
|
|
1400
|
+
// src/systems/physics-update.ts
|
|
1392
1401
|
var Zn = {
|
|
1393
1402
|
x: 0,
|
|
1394
1403
|
y: 0
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1404
|
+
}, Qn = [
|
|
1405
|
+
"transform",
|
|
1406
|
+
"velocity",
|
|
1407
|
+
"interpolation"
|
|
1408
|
+
];
|
|
1409
|
+
function $n(e = {}) {
|
|
1397
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) => {
|
|
1398
1411
|
if (c.entity?.[n] === 1) return;
|
|
1399
|
-
if (c.body !== void 0 &&
|
|
1412
|
+
if (c.body !== void 0 && Ae(c.body)) {
|
|
1400
1413
|
u.entityDied(r);
|
|
1401
1414
|
return;
|
|
1402
1415
|
}
|
|
1403
|
-
let d = i ?
|
|
1416
|
+
let d = i ? tr(c, i) : 0;
|
|
1404
1417
|
if (i && e.skipGroup === d) return;
|
|
1405
1418
|
let f = {
|
|
1406
1419
|
entityId: r,
|
|
@@ -1408,28 +1421,33 @@ function Qn(e = {}) {
|
|
|
1408
1421
|
}, p = c.interpolation, m = e.elapsedTime / 1e3;
|
|
1409
1422
|
Fn(e, r, c.velocity, c.dynamics);
|
|
1410
1423
|
let h = c.velocity[0] * m, g = c.velocity[1] * m;
|
|
1411
|
-
|
|
1424
|
+
or(p, c.transform, e);
|
|
1412
1425
|
let _ = i ? s?.get(d) : o;
|
|
1413
1426
|
if (!_) {
|
|
1414
|
-
|
|
1427
|
+
cr(r, c.transform, h, g, u, e.reportMoves), Q(e, r, c), sr(p, e.tick);
|
|
1415
1428
|
return;
|
|
1416
1429
|
}
|
|
1417
1430
|
let v = c.bounciness !== void 0, y = _.resolveMove(f, h, g, !v);
|
|
1418
|
-
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) {
|
|
1419
1432
|
_.forEachOverlapping(f, (n) => {
|
|
1420
|
-
_.claimContact(r, n.entityId) &&
|
|
1433
|
+
_.claimContact(r, n.entityId) && nr(e, _, f, n, l, u, y.moveX, y.moveY, a, t);
|
|
1421
1434
|
}, y.moveX, y.moveY);
|
|
1422
|
-
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);
|
|
1423
1436
|
}
|
|
1424
1437
|
}, { physics: {
|
|
1425
1438
|
collision: !0,
|
|
1426
1439
|
dynamics: !0,
|
|
1427
1440
|
optional: r,
|
|
1428
|
-
group: i
|
|
1441
|
+
group: i,
|
|
1442
|
+
writes: t ? [
|
|
1443
|
+
...Qn,
|
|
1444
|
+
"body",
|
|
1445
|
+
"entity"
|
|
1446
|
+
] : [...Qn]
|
|
1429
1447
|
} });
|
|
1430
1448
|
return l.preRun = (e, t, n) => {
|
|
1431
|
-
|
|
1432
|
-
|
|
1449
|
+
er(e, c), e.dieAtImpact = (t, n) => {
|
|
1450
|
+
ir(e, i ? s?.get(tr(t.components, i)) : o, t, n);
|
|
1433
1451
|
};
|
|
1434
1452
|
let r = e.elapsedTime / 1e3, a = n.collidable ?? [];
|
|
1435
1453
|
if (!i) {
|
|
@@ -1438,7 +1456,7 @@ function Qn(e = {}) {
|
|
|
1438
1456
|
}
|
|
1439
1457
|
let l = /* @__PURE__ */ new Map();
|
|
1440
1458
|
for (let t of a) {
|
|
1441
|
-
let n =
|
|
1459
|
+
let n = tr(t.components, i);
|
|
1442
1460
|
if (e.skipGroup === n) continue;
|
|
1443
1461
|
let r = l.get(n);
|
|
1444
1462
|
r || (r = [], l.set(n, r)), r.push(t);
|
|
@@ -1447,7 +1465,7 @@ function Qn(e = {}) {
|
|
|
1447
1465
|
for (let [t, n] of l) s.set(t, new Sn(n, r, e.dynamicsCommands));
|
|
1448
1466
|
}, l;
|
|
1449
1467
|
}
|
|
1450
|
-
function
|
|
1468
|
+
function er(e, t) {
|
|
1451
1469
|
let n = e, r = e.commandQueueId ?? 0, i = t.get(r);
|
|
1452
1470
|
i && (e.dynamicsCommands = Gn(i, e.dynamicsCommands), t.delete(r));
|
|
1453
1471
|
let a = () => {
|
|
@@ -1462,26 +1480,26 @@ function $n(e, t) {
|
|
|
1462
1480
|
Yn(a(), e, t);
|
|
1463
1481
|
};
|
|
1464
1482
|
}
|
|
1465
|
-
function
|
|
1483
|
+
function tr(e, t) {
|
|
1466
1484
|
let n = e[t.component];
|
|
1467
1485
|
return n ? n[t.index] : 0;
|
|
1468
1486
|
}
|
|
1469
|
-
function
|
|
1487
|
+
function nr(e, t, n, r, i, a, o, s, c, l) {
|
|
1470
1488
|
if (Ln(n, r, c), !l) return;
|
|
1471
1489
|
let u = J(n.components), d = J(r.components);
|
|
1472
1490
|
Zn.x = 0, Zn.y = 0, t.contactNormal(n, r, o, s, Zn), l(e, n, r, i, a, {
|
|
1473
1491
|
normalX: Zn.x,
|
|
1474
1492
|
normalY: Zn.y
|
|
1475
|
-
}),
|
|
1493
|
+
}), rr(e, n.entityId, n.components, u), rr(e, r.entityId, r.components, d);
|
|
1476
1494
|
}
|
|
1477
|
-
function
|
|
1495
|
+
function rr(e, t, n, r) {
|
|
1478
1496
|
let i = J(n);
|
|
1479
1497
|
(i.minX !== r.minX || i.minY !== r.minY || i.maxX !== r.maxX || i.maxY !== r.maxY) && Q(e, t, n);
|
|
1480
1498
|
}
|
|
1481
|
-
function
|
|
1499
|
+
function ir(e, t, n, r) {
|
|
1482
1500
|
let i = n.components.body;
|
|
1483
|
-
if (!i ||
|
|
1484
|
-
|
|
1501
|
+
if (!i || Ae(i)) return;
|
|
1502
|
+
je(i);
|
|
1485
1503
|
let a = n.components.transform, o = n.components.velocity, s = r.components.transform, c = r.components.body;
|
|
1486
1504
|
if (!t || !a || !o || !s || !c) return;
|
|
1487
1505
|
let l = e.elapsedTime / 1e3, u = o[0] * l, d = o[1] * l;
|
|
@@ -1498,46 +1516,44 @@ function rr(e, t, n, r) {
|
|
|
1498
1516
|
} }, u, d);
|
|
1499
1517
|
a[0] = f.x, a[1] = f.y;
|
|
1500
1518
|
}
|
|
1501
|
-
function
|
|
1519
|
+
function ar(e, t, n, r, i) {
|
|
1502
1520
|
let a = e.elapsedTime / 1e3, o = n.interpolation;
|
|
1503
|
-
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);
|
|
1504
1522
|
}
|
|
1505
|
-
function
|
|
1523
|
+
function or(e, t, n) {
|
|
1506
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);
|
|
1507
1525
|
}
|
|
1508
|
-
function
|
|
1526
|
+
function sr(e, t) {
|
|
1509
1527
|
e && a(e, 4, t);
|
|
1510
1528
|
}
|
|
1511
|
-
function
|
|
1529
|
+
function cr(e, t, n, r, i, a) {
|
|
1512
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));
|
|
1513
1531
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
var cr = /* @__PURE__ */ new WeakMap();
|
|
1517
|
-
function lr(e, t) {
|
|
1518
|
-
let n = cr.get(e);
|
|
1519
|
-
return n || (n = [void 0], cr.set(e, n)), n.push(t), n.length - 1;
|
|
1520
|
-
}
|
|
1532
|
+
// src/systems/interpolation-channels.ts
|
|
1533
|
+
var lr = /* @__PURE__ */ new WeakMap();
|
|
1521
1534
|
function ur(e, t) {
|
|
1522
|
-
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);
|
|
1523
1540
|
n && t > 0 && t < n.length && (n[t] = void 0);
|
|
1524
1541
|
}
|
|
1525
|
-
function
|
|
1526
|
-
let t =
|
|
1542
|
+
function fr(e) {
|
|
1543
|
+
let t = lr.get(e);
|
|
1527
1544
|
if (t) return t.map((e) => e ? e.committedTick : NaN);
|
|
1528
1545
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
var fr = 1, pr = class extends r {
|
|
1546
|
+
// src/systems/physics-system.ts
|
|
1547
|
+
var pr = 1, mr = class extends r {
|
|
1532
1548
|
spatialWorld;
|
|
1533
1549
|
pendingDynamicsCommands = /* @__PURE__ */ new Map();
|
|
1534
|
-
commandQueueId =
|
|
1550
|
+
commandQueueId = pr++;
|
|
1535
1551
|
tick = 0;
|
|
1536
1552
|
interpolationChannel;
|
|
1537
1553
|
reportMoves;
|
|
1538
1554
|
skipGroup;
|
|
1539
1555
|
constructor(e, t = {}) {
|
|
1540
|
-
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 = [];
|
|
1541
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);
|
|
1542
1558
|
let c = s.length ? [...s, ...r] : r, l = r.includes("bounciness") ? [...r] : ["bounciness", ...r];
|
|
1543
1559
|
l.includes("polygon") || l.push("polygon"), a && !l.includes("dynamics") && l.push("dynamics"), o && !l.includes(o.component) && l.push(o.component);
|
|
@@ -1552,11 +1568,14 @@ var fr = 1, pr = class extends r {
|
|
|
1552
1568
|
} } : void 0, f = d || t.queries ? {
|
|
1553
1569
|
...d,
|
|
1554
1570
|
...t.queries
|
|
1555
|
-
} : void 0, p =
|
|
1571
|
+
} : void 0, p = hr(t.scope, t.filter);
|
|
1556
1572
|
super(e, {
|
|
1557
1573
|
name: t.name ?? "PhysicsSystem",
|
|
1558
1574
|
deltaBetweenRuns: t.deltaBetweenRuns ?? 50,
|
|
1559
1575
|
firstRun: t.firstRun,
|
|
1576
|
+
reads: t.reads,
|
|
1577
|
+
writes: [.../* @__PURE__ */ new Set([...n.physics?.writes ?? Qn, ...t.writes ?? []])],
|
|
1578
|
+
exclusive: t.exclusive,
|
|
1560
1579
|
required: ["transform", "velocity"],
|
|
1561
1580
|
optional: c,
|
|
1562
1581
|
filter: p,
|
|
@@ -1566,13 +1585,13 @@ var fr = 1, pr = class extends r {
|
|
|
1566
1585
|
getWorker: t.getWorker ?? (() => {
|
|
1567
1586
|
throw Error("PhysicsSystem cannot start a worker: no getWorker was supplied");
|
|
1568
1587
|
})
|
|
1569
|
-
}), 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);
|
|
1570
1589
|
}
|
|
1571
1590
|
get committedTick() {
|
|
1572
1591
|
return this.isCurrentlyRunning() ? this.tick - 1 : this.tick;
|
|
1573
1592
|
}
|
|
1574
1593
|
destroy() {
|
|
1575
|
-
|
|
1594
|
+
dr(this.world, this.interpolationChannel), super.destroy();
|
|
1576
1595
|
}
|
|
1577
1596
|
startInterpolation(e) {
|
|
1578
1597
|
let t = this.deltaBetweenRuns;
|
|
@@ -1613,12 +1632,11 @@ var fr = 1, pr = class extends r {
|
|
|
1613
1632
|
return n;
|
|
1614
1633
|
}
|
|
1615
1634
|
};
|
|
1616
|
-
function
|
|
1635
|
+
function hr(e, t) {
|
|
1617
1636
|
return e ? t ? (n) => e(n) && t(n) : e : t;
|
|
1618
1637
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
var hr = 0, gr = class e {
|
|
1638
|
+
// src/pathfinding/nav-grid.ts
|
|
1639
|
+
var gr = 0, _r = class e {
|
|
1622
1640
|
tilesWide;
|
|
1623
1641
|
tilesHigh;
|
|
1624
1642
|
cellSize;
|
|
@@ -1705,14 +1723,14 @@ var hr = 0, gr = class e {
|
|
|
1705
1723
|
return this.cellSize / this.speeds[this.index(e, t)];
|
|
1706
1724
|
}
|
|
1707
1725
|
region(e, t) {
|
|
1708
|
-
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;
|
|
1709
1727
|
}
|
|
1710
1728
|
rebuildRegions() {
|
|
1711
1729
|
let e = this.regions;
|
|
1712
|
-
e.fill(
|
|
1713
|
-
let t = new Int32Array(this.tileCount), n =
|
|
1730
|
+
e.fill(gr);
|
|
1731
|
+
let t = new Int32Array(this.tileCount), n = gr;
|
|
1714
1732
|
for (let r = 0; r < e.length; r++) {
|
|
1715
|
-
if (e[r] !==
|
|
1733
|
+
if (e[r] !== gr || this.blockers[r] > 0) continue;
|
|
1716
1734
|
n++, e[r] = n;
|
|
1717
1735
|
let i = 0, a = 0;
|
|
1718
1736
|
for (t[a++] = r; i < a;) {
|
|
@@ -1725,9 +1743,9 @@ var hr = 0, gr = class e {
|
|
|
1725
1743
|
flood(e, t, n, r, i) {
|
|
1726
1744
|
if (!this.inBounds(e, t)) return i;
|
|
1727
1745
|
let a = this.index(e, t);
|
|
1728
|
-
return this.regions[a] !==
|
|
1746
|
+
return this.regions[a] !== gr || this.blockers[a] > 0 ? i : (this.regions[a] = n, r[i] = a, i + 1);
|
|
1729
1747
|
}
|
|
1730
|
-
},
|
|
1748
|
+
}, vr = class {
|
|
1731
1749
|
ids;
|
|
1732
1750
|
primary;
|
|
1733
1751
|
secondary;
|
|
@@ -1778,9 +1796,8 @@ var hr = 0, gr = class e {
|
|
|
1778
1796
|
t.set(this.ids), n.set(this.primary), r.set(this.secondary), this.ids = t, this.primary = n, this.secondary = r;
|
|
1779
1797
|
}
|
|
1780
1798
|
};
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
function vr(e, t, n, r, i, a, o) {
|
|
1799
|
+
// src/pathfinding/line-of-sight.ts
|
|
1800
|
+
function yr(e, t, n, r, i, a, o) {
|
|
1784
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;
|
|
1785
1802
|
for (let r = d; r <= f; r++) {
|
|
1786
1803
|
let i = (r + .5) * s, o, d;
|
|
@@ -1801,74 +1818,72 @@ function vr(e, t, n, r, i, a, o) {
|
|
|
1801
1818
|
}
|
|
1802
1819
|
return p;
|
|
1803
1820
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
let a = Cr(t);
|
|
1821
|
+
// src/pathfinding/smooth-path.ts
|
|
1822
|
+
var br = 24;
|
|
1823
|
+
function xr(e, t, n, r, i) {
|
|
1824
|
+
let a = wr(t);
|
|
1809
1825
|
if (a.length <= 2) return a;
|
|
1810
1826
|
let o = new Float64Array(a.length);
|
|
1811
|
-
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);
|
|
1812
1828
|
let s = [0];
|
|
1813
|
-
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);
|
|
1814
1830
|
s.push(a.length - 1);
|
|
1815
1831
|
let c = [a[0]], l = 0;
|
|
1816
1832
|
for (; l < s.length - 1;) {
|
|
1817
|
-
let t = l + 1, u = Math.min(s.length - 1, l +
|
|
1833
|
+
let t = l + 1, u = Math.min(s.length - 1, l + br);
|
|
1818
1834
|
for (let c = l + 2; c <= u; c++) {
|
|
1819
|
-
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;
|
|
1820
1836
|
Number.isFinite(p) && p <= o[s[c]] - o[s[l]] + 1e-6 && (t = c);
|
|
1821
1837
|
}
|
|
1822
1838
|
c.push(a[s[t]]), l = t;
|
|
1823
1839
|
}
|
|
1824
1840
|
return c;
|
|
1825
1841
|
}
|
|
1826
|
-
function
|
|
1827
|
-
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);
|
|
1828
1844
|
return a * (Number.isFinite(o) ? o : 1 / e.terrainSpeed(e.tileOf(n.x), e.tileOf(n.y)));
|
|
1829
1845
|
}
|
|
1830
|
-
function
|
|
1846
|
+
function Cr(e, t, n) {
|
|
1831
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;
|
|
1832
1848
|
}
|
|
1833
|
-
function
|
|
1849
|
+
function wr(e) {
|
|
1834
1850
|
let t = [];
|
|
1835
1851
|
for (let n of e) {
|
|
1836
1852
|
let e = t[t.length - 1];
|
|
1837
|
-
|
|
1853
|
+
e && e.x === n.x && e.y === n.y || t.push(n);
|
|
1838
1854
|
}
|
|
1839
1855
|
return t;
|
|
1840
1856
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
1857
|
+
// src/pathfinding/grid-a-star.ts
|
|
1858
|
+
var Tr = 5e4, Er = 0, Dr = 16, Or = [
|
|
1844
1859
|
[-1, 0],
|
|
1845
1860
|
[1, 0],
|
|
1846
1861
|
[0, -1],
|
|
1847
1862
|
[0, 1]
|
|
1848
|
-
],
|
|
1863
|
+
], kr = [
|
|
1849
1864
|
[-1, -1],
|
|
1850
1865
|
[1, -1],
|
|
1851
1866
|
[-1, 1],
|
|
1852
1867
|
[1, 1]
|
|
1853
|
-
],
|
|
1868
|
+
], Ar = class {
|
|
1854
1869
|
diagonal;
|
|
1855
1870
|
maxIterations;
|
|
1856
1871
|
smooth;
|
|
1857
1872
|
clearance;
|
|
1858
1873
|
relocateRadius;
|
|
1859
|
-
heap = new
|
|
1874
|
+
heap = new vr(256);
|
|
1860
1875
|
cost = /* @__PURE__ */ new Float64Array();
|
|
1861
1876
|
parent = /* @__PURE__ */ new Int32Array();
|
|
1862
1877
|
seen = /* @__PURE__ */ new Uint32Array();
|
|
1863
1878
|
closed = /* @__PURE__ */ new Uint32Array();
|
|
1864
1879
|
stamp = 0;
|
|
1865
1880
|
constructor(e = {}) {
|
|
1866
|
-
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;
|
|
1867
1882
|
}
|
|
1868
1883
|
findPath(e, t) {
|
|
1869
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));
|
|
1870
1885
|
if (r > e.tilesWide || i > e.tilesHigh) return {
|
|
1871
|
-
status:
|
|
1886
|
+
status: L.Unreachable,
|
|
1872
1887
|
points: [],
|
|
1873
1888
|
iterations: 0
|
|
1874
1889
|
};
|
|
@@ -1876,14 +1891,14 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1876
1891
|
x: Math.round((e - r * n / 2) / n),
|
|
1877
1892
|
y: Math.round((t - i * n / 2) / n)
|
|
1878
1893
|
}), o = (t) => ({
|
|
1879
|
-
x:
|
|
1880
|
-
y:
|
|
1894
|
+
x: Mr(t.x, 0, e.tilesWide - r),
|
|
1895
|
+
y: Mr(t.y, 0, e.tilesHigh - i)
|
|
1881
1896
|
}), s = (e) => ({
|
|
1882
1897
|
x: (e.x + r / 2) * n,
|
|
1883
1898
|
y: (e.y + i / 2) * n
|
|
1884
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);
|
|
1885
1900
|
if (!c || !u || e.region(c.x, c.y) !== e.region(u.x, u.y)) return {
|
|
1886
|
-
status:
|
|
1901
|
+
status: L.Unreachable,
|
|
1887
1902
|
points: [],
|
|
1888
1903
|
iterations: 0
|
|
1889
1904
|
};
|
|
@@ -1896,14 +1911,14 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1896
1911
|
y: Math.floor(t / e.tilesWide)
|
|
1897
1912
|
}));
|
|
1898
1913
|
let m = f.status;
|
|
1899
|
-
if (m ===
|
|
1914
|
+
if (m === L.Found) {
|
|
1900
1915
|
let n = s(u);
|
|
1901
|
-
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({
|
|
1902
1917
|
x: t.goalX,
|
|
1903
1918
|
y: t.goalY
|
|
1904
1919
|
});
|
|
1905
1920
|
}
|
|
1906
|
-
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);
|
|
1907
1922
|
return {
|
|
1908
1923
|
status: m,
|
|
1909
1924
|
points: _.slice(1),
|
|
@@ -1941,23 +1956,23 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1941
1956
|
let t = u.pop();
|
|
1942
1957
|
if (l[t] === a) continue;
|
|
1943
1958
|
if (t === p) return {
|
|
1944
|
-
status:
|
|
1959
|
+
status: L.Found,
|
|
1945
1960
|
tiles: this.trace(t),
|
|
1946
1961
|
iterations: v
|
|
1947
1962
|
};
|
|
1948
1963
|
if (v >= this.maxIterations) return {
|
|
1949
|
-
status:
|
|
1964
|
+
status: L.Incomplete,
|
|
1950
1965
|
tiles: this.trace(g),
|
|
1951
1966
|
iterations: v
|
|
1952
1967
|
};
|
|
1953
1968
|
l[t] = a, v++;
|
|
1954
1969
|
let n = t % d, s = (t - n) / d, c = h(n, s);
|
|
1955
1970
|
(c < _ || c === _ && o[t] < o[g]) && (g = t, _ = c);
|
|
1956
|
-
for (let [a, o] of
|
|
1957
|
-
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);
|
|
1958
1973
|
}
|
|
1959
1974
|
return {
|
|
1960
|
-
status:
|
|
1975
|
+
status: L.Unreachable,
|
|
1961
1976
|
tiles: this.trace(g),
|
|
1962
1977
|
iterations: v
|
|
1963
1978
|
};
|
|
@@ -1966,7 +1981,7 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1966
1981
|
if (!e.isAreaClear(n, r, a, o)) return;
|
|
1967
1982
|
let c = e.index(n, r);
|
|
1968
1983
|
if (this.closed[c] === this.stamp) return;
|
|
1969
|
-
let l = this.cost[t] + i *
|
|
1984
|
+
let l = this.cost[t] + i * jr(e, n, r, a, o);
|
|
1970
1985
|
if (this.seen[c] === this.stamp && l >= this.cost[c]) return;
|
|
1971
1986
|
this.seen[c] = this.stamp, this.cost[c] = l, this.parent[c] = t;
|
|
1972
1987
|
let u = s(n, r);
|
|
@@ -1983,38 +1998,36 @@ var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
|
1983
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);
|
|
1984
1999
|
}
|
|
1985
2000
|
};
|
|
1986
|
-
function
|
|
2001
|
+
function jr(e, t, n, r, i) {
|
|
1987
2002
|
if (r === 1 && i === 1) return e.cost(t, n);
|
|
1988
2003
|
let a = 0;
|
|
1989
2004
|
for (let o = n; o < n + i; o++) for (let n = t; n < t + r; n++) a += e.cost(n, o);
|
|
1990
2005
|
return a / (r * i);
|
|
1991
2006
|
}
|
|
1992
|
-
function
|
|
2007
|
+
function Mr(e, t, n) {
|
|
1993
2008
|
return Math.min(n, Math.max(t, e));
|
|
1994
2009
|
}
|
|
1995
|
-
function
|
|
2010
|
+
function Nr(e) {
|
|
1996
2011
|
return e.filter((t, n) => n === 0 || t.x !== e[n - 1].x || t.y !== e[n - 1].y);
|
|
1997
2012
|
}
|
|
1998
|
-
|
|
1999
|
-
//#region src/pathfinding/follow-path.ts
|
|
2013
|
+
// src/pathfinding/follow-path.ts
|
|
2000
2014
|
var $ = {
|
|
2001
2015
|
Waiting: 0,
|
|
2002
2016
|
Waypoint: 1,
|
|
2003
2017
|
Goal: 2,
|
|
2004
2018
|
Stuck: 3
|
|
2005
2019
|
};
|
|
2006
|
-
function
|
|
2007
|
-
if (
|
|
2020
|
+
function Pr(e, t, n, r, a) {
|
|
2021
|
+
if (wt(e)) return $.Waiting;
|
|
2008
2022
|
let o = e[4], s = e[3];
|
|
2009
|
-
for (; s < o && Math.hypot(
|
|
2010
|
-
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;
|
|
2011
2025
|
let c = e[2];
|
|
2012
|
-
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;
|
|
2013
2027
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
function Ir(e = {}) {
|
|
2028
|
+
// src/pathfinding/path-blockers.ts
|
|
2029
|
+
var Fr = "pathBlockers", Ir = "pathGates";
|
|
2030
|
+
function Lr(e = {}) {
|
|
2018
2031
|
let { gateCategories: t = 0, not: n, filter: r } = e, i = {
|
|
2019
2032
|
required: ["transform", "body"],
|
|
2020
2033
|
not: n,
|
|
@@ -2023,7 +2036,7 @@ function Ir(e = {}) {
|
|
|
2023
2036
|
return !!t && t.blocksPath && !t.sensor && (!r || r(e));
|
|
2024
2037
|
}
|
|
2025
2038
|
};
|
|
2026
|
-
if (!t) return { [
|
|
2039
|
+
if (!t) return { [Fr]: i };
|
|
2027
2040
|
let a = {
|
|
2028
2041
|
required: ["transform", "body"],
|
|
2029
2042
|
not: n,
|
|
@@ -2033,12 +2046,12 @@ function Ir(e = {}) {
|
|
|
2033
2046
|
}
|
|
2034
2047
|
};
|
|
2035
2048
|
return {
|
|
2036
|
-
[
|
|
2037
|
-
[
|
|
2049
|
+
[Fr]: i,
|
|
2050
|
+
[Ir]: a
|
|
2038
2051
|
};
|
|
2039
2052
|
}
|
|
2040
|
-
function
|
|
2041
|
-
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];
|
|
2042
2055
|
return {
|
|
2043
2056
|
minX: c - o,
|
|
2044
2057
|
minY: l - s,
|
|
@@ -2046,7 +2059,7 @@ function Lr(e, t) {
|
|
|
2046
2059
|
maxY: l + s
|
|
2047
2060
|
};
|
|
2048
2061
|
}
|
|
2049
|
-
function
|
|
2062
|
+
function zr(e, t, n) {
|
|
2050
2063
|
let r = [...t];
|
|
2051
2064
|
for (let t of n.removed) {
|
|
2052
2065
|
let n = e.get(t);
|
|
@@ -2060,27 +2073,26 @@ function Rr(e, t, n) {
|
|
|
2060
2073
|
e.delete(t);
|
|
2061
2074
|
continue;
|
|
2062
2075
|
}
|
|
2063
|
-
let s =
|
|
2076
|
+
let s = Rr(a, o);
|
|
2064
2077
|
r.forEach((e) => e.addBlocker(s)), e.set(t, s);
|
|
2065
2078
|
}
|
|
2066
2079
|
return n.added.length > 0;
|
|
2067
2080
|
}
|
|
2068
|
-
function
|
|
2081
|
+
function Br(e) {
|
|
2069
2082
|
let t = Math.round(e / (Math.PI / 2)) * Math.PI / 2;
|
|
2070
2083
|
return Math.abs(e - t) < 1e-5 ? t : e;
|
|
2071
2084
|
}
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
function Br(e, t, n, r = 0) {
|
|
2085
|
+
// src/pathfinding/navigation-state.ts
|
|
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,52 +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
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
let t = e.search ?? new kr({ diagonal: !0 }), n = e.iterationBudget ?? 16e3, r = e.gateCategories ?? 0, a = (e, r, a) => {
|
|
2142
|
+
// src/pathfinding/pathfinding-update.ts
|
|
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) => {
|
|
2135
2146
|
let { navigation: o, transform: s, body: c } = a;
|
|
2136
2147
|
if (!o[5]) return;
|
|
2137
|
-
let l = c ? c[2] : 0, u =
|
|
2148
|
+
let l = c ? c[2] : 0, u = Hr(e.navigation, l), d = Atomics.load(o, 0);
|
|
2138
2149
|
if (d === Atomics.load(o, 1)) {
|
|
2139
|
-
if (!e.blockersAdded ||
|
|
2150
|
+
if (!e.blockersAdded || Qr(u, o, s)) return;
|
|
2140
2151
|
d = Atomics.add(o, 0, 1) + 1;
|
|
2141
2152
|
}
|
|
2142
2153
|
if ((e.searchIterations ?? 0) >= (e.iterationBudget ?? n)) return;
|
|
@@ -2147,19 +2158,19 @@ function Jr(e = {}) {
|
|
|
2147
2158
|
goalY: i(o, 7),
|
|
2148
2159
|
agentWidth: s[2],
|
|
2149
2160
|
agentHeight: s[3]
|
|
2150
|
-
}, p =
|
|
2161
|
+
}, p = Zr(e.navigation, u, l, f);
|
|
2151
2162
|
p.forEach((e) => u.removeBlocker(e));
|
|
2152
2163
|
let m = t.findPath(u, f);
|
|
2153
2164
|
p.forEach((e) => u.addBlocker(e)), e.searchIterations = (e.searchIterations ?? 0) + m.iterations;
|
|
2154
|
-
let h = m.status ===
|
|
2155
|
-
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);
|
|
2156
2167
|
};
|
|
2157
2168
|
return a.init = (t, n, i, a) => {
|
|
2158
|
-
let o =
|
|
2159
|
-
return
|
|
2169
|
+
let o = Vr(n?.tilesWide ?? 1, n?.tilesHigh ?? 1, n?.cellSize ?? 1, r);
|
|
2170
|
+
return Gr(o, {
|
|
2160
2171
|
added: a.pathBlockers ?? [],
|
|
2161
2172
|
removed: []
|
|
2162
|
-
}),
|
|
2173
|
+
}), Kr(o, {
|
|
2163
2174
|
added: a.pathGates ?? [],
|
|
2164
2175
|
removed: []
|
|
2165
2176
|
}), {
|
|
@@ -2167,13 +2178,13 @@ function Jr(e = {}) {
|
|
|
2167
2178
|
navigation: o
|
|
2168
2179
|
};
|
|
2169
2180
|
}, a.queryChanged = (t, n, r, i) => {
|
|
2170
|
-
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);
|
|
2171
2182
|
}, a.preRun = (t, n, r, i) => {
|
|
2172
2183
|
t.searchIterations = 0, e.preRun?.(t, n, r, i);
|
|
2173
2184
|
}, Object.assign(a, { pathfinding: { gateCategories: r } });
|
|
2174
2185
|
}
|
|
2175
|
-
var
|
|
2176
|
-
function
|
|
2186
|
+
var Xr = Yr();
|
|
2187
|
+
function Zr(e, t, n, r) {
|
|
2177
2188
|
let i = r.agentWidth / 2, a = r.agentHeight / 2, o = {
|
|
2178
2189
|
minX: r.startX - i,
|
|
2179
2190
|
minY: r.startY - a,
|
|
@@ -2181,34 +2192,36 @@ function Xr(e, t, n, r) {
|
|
|
2181
2192
|
maxY: r.startY + a
|
|
2182
2193
|
}, s = t.tilesIn(o), c = !0;
|
|
2183
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;
|
|
2184
|
-
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);
|
|
2185
2196
|
}
|
|
2186
|
-
function
|
|
2197
|
+
function Qr(e, t, n) {
|
|
2187
2198
|
let r = n[2] / 2, a = n[3] / 2, o = n[0], s = n[1], c = t[4];
|
|
2188
2199
|
for (let n = t[3]; n <= c; n++) {
|
|
2189
2200
|
let l, u;
|
|
2190
|
-
if (n < c) l =
|
|
2191
|
-
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);
|
|
2192
2203
|
else break;
|
|
2193
|
-
if (!Number.isFinite(
|
|
2204
|
+
if (!Number.isFinite(yr(e, o, s, l, u, r, a))) return !1;
|
|
2194
2205
|
o = l, s = u;
|
|
2195
2206
|
}
|
|
2196
2207
|
return !0;
|
|
2197
2208
|
}
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
var Qr = class extends r {
|
|
2209
|
+
// src/pathfinding/pathfinding-system.ts
|
|
2210
|
+
var $r = class extends r {
|
|
2201
2211
|
iterationBudget;
|
|
2202
2212
|
constructor(e, t) {
|
|
2203
|
-
let n = t.updateFunction ??
|
|
2213
|
+
let n = t.updateFunction ?? Yr(), r = t.optional ?? [];
|
|
2204
2214
|
super(e, {
|
|
2205
2215
|
name: t.name ?? "PathfindingSystem",
|
|
2206
2216
|
deltaBetweenRuns: t.deltaBetweenRuns ?? 50,
|
|
2207
2217
|
firstRun: t.firstRun,
|
|
2218
|
+
reads: t.reads,
|
|
2219
|
+
writes: [.../* @__PURE__ */ new Set(["navigation", ...t.writes ?? []])],
|
|
2220
|
+
exclusive: t.exclusive,
|
|
2208
2221
|
required: ["navigation", "transform"],
|
|
2209
2222
|
optional: r.includes("body") ? r : ["body", ...r],
|
|
2210
2223
|
queries: {
|
|
2211
|
-
...
|
|
2224
|
+
...Lr({
|
|
2212
2225
|
...t.blockers,
|
|
2213
2226
|
gateCategories: n.pathfinding.gateCategories
|
|
2214
2227
|
}),
|
|
@@ -2232,7 +2245,7 @@ var Qr = class extends r {
|
|
|
2232
2245
|
finishLoading() {
|
|
2233
2246
|
return this.loaded = !0, super.finishLoading();
|
|
2234
2247
|
}
|
|
2235
|
-
},
|
|
2248
|
+
}, ei = (e, t, n) => {
|
|
2236
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]];
|
|
2237
2250
|
if (h !== void 0 && !Number.isNaN(h) && !(m && d <= h)) {
|
|
2238
2251
|
let e = i(r, 16);
|
|
@@ -2260,14 +2273,15 @@ var Qr = class extends r {
|
|
|
2260
2273
|
y > v && (_ += Math.min(y - v, _ * p));
|
|
2261
2274
|
let b = _ / g, x = r[0], S = r[1];
|
|
2262
2275
|
r[0] = x + (l - x) * b, r[1] = S + (u - S) * b, r[7] = g - _;
|
|
2263
|
-
},
|
|
2276
|
+
}, ti = class extends r {
|
|
2264
2277
|
constructor(e, t = {}) {
|
|
2265
2278
|
super(e, {
|
|
2266
2279
|
name: t.name ?? "InterpolationSystem",
|
|
2267
2280
|
deltaBetweenRuns: 0,
|
|
2268
2281
|
firstRun: t.firstRun,
|
|
2282
|
+
writes: ["interpolation"],
|
|
2269
2283
|
required: ["transform", "interpolation"],
|
|
2270
|
-
updateFunction:
|
|
2284
|
+
updateFunction: ei,
|
|
2271
2285
|
forceMainThread: t.forceMainThread ?? !t.getWorker,
|
|
2272
2286
|
getWorker: t.getWorker ?? (() => {
|
|
2273
2287
|
throw Error("InterpolationSystem cannot start a worker: no getWorker was supplied");
|
|
@@ -2275,10 +2289,9 @@ var Qr = class extends r {
|
|
|
2275
2289
|
});
|
|
2276
2290
|
}
|
|
2277
2291
|
addDataToWorld(e) {
|
|
2278
|
-
e.committedTicks =
|
|
2292
|
+
e.committedTicks = fr(this.world);
|
|
2279
2293
|
}
|
|
2280
2294
|
};
|
|
2281
|
-
|
|
2282
|
-
export { Ee as BODY_BLOCKS_PATH_FLAG, ye as BODY_CATEGORY_INDEX, we as BODY_CCD_FLAG, Te as BODY_DYING_FLAG, ve as BODY_FLAGS_INDEX, be as BODY_MASK_INDEX, Ce as BODY_SENSOR_FLAG, Se as BODY_SHAPE_MASK, xe as BODY_SIZE, Le as BOUNCINESS_INDEX, Re as BOUNCINESS_SIZE, u as COLLIDABLE_QUERY, Sn as CollisionBroadphase, ge as DEFAULT_COLLIDE_CATEGORY, _e as DEFAULT_COLLIDE_MASK, qr as DEFAULT_PATH_SEARCH_ITERATION_BUDGET, d as DEFAULT_PHYSICS_STEP_MS, ie as DYNAMICS_ACCELERATION_X_INDEX, ae as DYNAMICS_ACCELERATION_Y_INDEX, oe as DYNAMICS_INVERSE_MASS_INDEX, se as DYNAMICS_SIZE, $ as FollowStep, kr as GridAStar, Qe as INTERPOLATION_CHANNEL_INDEX, We as INTERPOLATION_DURATION_INDEX, tt as INTERPOLATION_PREVIOUS_DURATION_INDEX, rt as INTERPOLATION_PREVIOUS_TICK_INDEX, nt as INTERPOLATION_PREVIOUS_TOTAL_DURATION_INDEX, $e as INTERPOLATION_PREVIOUS_X_INDEX, et as INTERPOLATION_PREVIOUS_Y_INDEX, Je as INTERPOLATION_REMAINING_DURATION_INDEX, it as INTERPOLATION_SIZE, qe as INTERPOLATION_SYNCED_DURATION_INDEX, Ze as INTERPOLATION_SYNCED_STEP_DURATION_INDEX, Ue as INTERPOLATION_SYNCED_TICK_INDEX, Ye as INTERPOLATION_TARGET_X_INDEX, Xe as INTERPOLATION_TARGET_Y_INDEX, Ge as INTERPOLATION_TICK_INDEX, Ke as INTERPOLATION_TOTAL_DURATION_INDEX, Ve as INTERPOLATION_X_INDEX, He as INTERPOLATION_Y_INDEX, ei as InterpolationSystem, b as MAX_POLYGON_VERTICES, _r as MinHeap, ft as NAVIGATION_ACTIVE_INDEX, pt as NAVIGATION_GOAL_X_INDEX, mt as NAVIGATION_GOAL_Y_INDEX, gt as NAVIGATION_MAX_WAYPOINTS, lt as NAVIGATION_OUTCOME_INDEX, st as NAVIGATION_REQUEST_INDEX, ct as NAVIGATION_RESULT_INDEX, _t as NAVIGATION_SIZE, ht as NAVIGATION_WAYPOINTS_INDEX, dt as NAVIGATION_WAYPOINT_COUNT_INDEX, ut as NAVIGATION_WAYPOINT_INDEX, gr as NavGrid, Pr as PATH_BLOCKERS_QUERY, Fr as PATH_GATES_QUERY, C as POLYGON_SIZE, x as POLYGON_VERTEX_COUNT_INDEX, S as POLYGON_VERTICES_INDEX, l as POSITION_UPDATED_EVENT, I as PathStatus, Qr as PathfindingSystem, $t as PhysicalWorld, pr as PhysicsSystem, me as SHAPE_CAPSULE, pe as SHAPE_CIRCLE, he as SHAPE_POLYGON, fe 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, ne as VELOCITY_SIZE, j as VELOCITY_X_INDEX, ee as VELOCITY_Y_INDEX, Mn as addPhysicalWorldData, Wr as applyPathBlockerChanges, Gr as applyPathGateChanges, Rr as applyRectChanges, Lr as blockerRect, Hr as blockingRects, Ae as blocksPath, Pe as bodyDefinition, P as bodyShape, Be as bouncinessDefinition, Gt as boundsHalfHeight, Wt as boundsHalfWidth, Oe as canCollide, V as capsuleCoreAngle, B as capsuleHalfLength, Lt as contactNormal, Br as createNavigationState, Jr as createPathfindingUpdate, Qn as createPhysicsUpdate, le as dynamicsDefinition, Nr as followPath, An as getSpatialMap, Fn as integrateDynamics, ot as interpolationDefinition, $r as interpolationUpdate, ke as isContinuous, je as isDying, Ct as isNavigating, Tt as isPathPending, F as isSensor, Et as isUnreachable, Me as markDying, bt as navigateTo, yt as navigationDefinition, Dt as navigationGoal, Vr as navigationGridFor, Mt as navigationRegistry, Kt as orientedBoxesOverlap, Ir as pathBlockerQueries, Yr as pathfindingUpdate, jt as physicsRegistry, ir as physicsUpdate, K as pointSegmentDistanceSquared, rn as polygonContactNormal, T as polygonDefinition, nn as polygonShapesOverlap, E as preparePolygon, wt as requestPath, Jt as segmentBoxDistanceSquared, qt as segmentSegmentDistanceSquared, jn as setEntityPosition, xt as setNavigationGoal, Ur as setNavigationTerrainSpeed, U as shapeHalfHeight, H as shapeHalfWidth, Pt as shapeIsEmpty, Nt as shapeRadius, Ft as shapesOverlap, br as smoothPath, Nn as snapEntity, Pn as startSpawnInterpolation, St as stopNavigating, vr as sweepCost, A as transformDefinition, Q as updateSpatialMap, M as velocityDefinition, Ot as waypoint, L as waypointX, kt as waypointY, At as writePath };
|
|
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 };
|
|
2283
2296
|
|
|
2284
2297
|
//# sourceMappingURL=index.js.map
|