@daneren2005/shared-memory-physics 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +80 -83
- package/dist/index.js.map +1 -1
- 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];
|
|
@@ -186,8 +185,7 @@ var k = class extends t {
|
|
|
186
185
|
function N(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
|
-
//#region src/components/dynamics-component-constants.ts
|
|
188
|
+
// src/components/dynamics-component-constants.ts
|
|
191
189
|
var ie = 0, ae = 1, oe = 2, se = 3, ce = class extends t {
|
|
192
190
|
get accelerationX() {
|
|
193
191
|
return this.block[0];
|
|
@@ -240,8 +238,7 @@ function ue(e) {
|
|
|
240
238
|
function de(e, t) {
|
|
241
239
|
if (!Number.isFinite(e)) throw Error(`${t} must be a finite number`);
|
|
242
240
|
}
|
|
243
|
-
|
|
244
|
-
//#region src/components/body-component-constants.ts
|
|
241
|
+
// src/components/body-component-constants.ts
|
|
245
242
|
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 = [
|
|
246
243
|
1,
|
|
247
244
|
2,
|
|
@@ -343,8 +340,7 @@ function Ie(e) {
|
|
|
343
340
|
if (t === 4 && e.vertices === void 0) throw Error("A polygon body requires vertices");
|
|
344
341
|
return t;
|
|
345
342
|
}
|
|
346
|
-
|
|
347
|
-
//#region src/components/bounciness-component-constants.ts
|
|
343
|
+
// src/components/bounciness-component-constants.ts
|
|
348
344
|
var Le = 0, Re = 1, ze = class extends t {
|
|
349
345
|
get bounciness() {
|
|
350
346
|
return this.block[0];
|
|
@@ -555,8 +551,7 @@ function At(e, t, n) {
|
|
|
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
552
|
e[4] = i, e[3] = 0, e[2] = r ? I.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
557
|
velocity: M,
|
|
@@ -694,8 +689,7 @@ 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
694
|
let t = e.transform, n = e.body ? P(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 {
|
|
@@ -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) => {
|
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -1181,8 +1206,7 @@ function Z(e, t, n, r) {
|
|
|
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;
|
|
@@ -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
|
|
@@ -1320,8 +1336,7 @@ function Un(e) {
|
|
|
1320
1336
|
function Wn(e) {
|
|
1321
1337
|
return e !== void 0 && F(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,8 +1397,7 @@ 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
|
|
@@ -1511,8 +1520,7 @@ function or(e, t) {
|
|
|
1511
1520
|
function sr(e, t, n, r, i, a) {
|
|
1512
1521
|
(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
1522
|
}
|
|
1514
|
-
|
|
1515
|
-
//#region src/systems/interpolation-channels.ts
|
|
1523
|
+
// src/systems/interpolation-channels.ts
|
|
1516
1524
|
var cr = /* @__PURE__ */ new WeakMap();
|
|
1517
1525
|
function lr(e, t) {
|
|
1518
1526
|
let n = cr.get(e);
|
|
@@ -1526,8 +1534,7 @@ function dr(e) {
|
|
|
1526
1534
|
let t = cr.get(e);
|
|
1527
1535
|
if (t) return t.map((e) => e ? e.committedTick : NaN);
|
|
1528
1536
|
}
|
|
1529
|
-
|
|
1530
|
-
//#region src/systems/physics-system.ts
|
|
1537
|
+
// src/systems/physics-system.ts
|
|
1531
1538
|
var fr = 1, pr = class extends r {
|
|
1532
1539
|
spatialWorld;
|
|
1533
1540
|
pendingDynamicsCommands = /* @__PURE__ */ new Map();
|
|
@@ -1616,8 +1623,7 @@ var fr = 1, pr = class extends r {
|
|
|
1616
1623
|
function mr(e, t) {
|
|
1617
1624
|
return e ? t ? (n) => e(n) && t(n) : e : t;
|
|
1618
1625
|
}
|
|
1619
|
-
|
|
1620
|
-
//#region src/pathfinding/nav-grid.ts
|
|
1626
|
+
// src/pathfinding/nav-grid.ts
|
|
1621
1627
|
var hr = 0, gr = class e {
|
|
1622
1628
|
tilesWide;
|
|
1623
1629
|
tilesHigh;
|
|
@@ -1778,8 +1784,7 @@ var hr = 0, gr = class e {
|
|
|
1778
1784
|
t.set(this.ids), n.set(this.primary), r.set(this.secondary), this.ids = t, this.primary = n, this.secondary = r;
|
|
1779
1785
|
}
|
|
1780
1786
|
};
|
|
1781
|
-
|
|
1782
|
-
//#region src/pathfinding/line-of-sight.ts
|
|
1787
|
+
// src/pathfinding/line-of-sight.ts
|
|
1783
1788
|
function vr(e, t, n, r, i, a, o) {
|
|
1784
1789
|
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
1790
|
for (let r = d; r <= f; r++) {
|
|
@@ -1801,8 +1806,7 @@ function vr(e, t, n, r, i, a, o) {
|
|
|
1801
1806
|
}
|
|
1802
1807
|
return p;
|
|
1803
1808
|
}
|
|
1804
|
-
|
|
1805
|
-
//#region src/pathfinding/smooth-path.ts
|
|
1809
|
+
// src/pathfinding/smooth-path.ts
|
|
1806
1810
|
var yr = 24;
|
|
1807
1811
|
function br(e, t, n, r, i) {
|
|
1808
1812
|
let a = Cr(t);
|
|
@@ -1834,12 +1838,11 @@ function Cr(e) {
|
|
|
1834
1838
|
let t = [];
|
|
1835
1839
|
for (let n of e) {
|
|
1836
1840
|
let e = t[t.length - 1];
|
|
1837
|
-
|
|
1841
|
+
e && e.x === n.x && e.y === n.y || t.push(n);
|
|
1838
1842
|
}
|
|
1839
1843
|
return t;
|
|
1840
1844
|
}
|
|
1841
|
-
|
|
1842
|
-
//#region src/pathfinding/grid-a-star.ts
|
|
1845
|
+
// src/pathfinding/grid-a-star.ts
|
|
1843
1846
|
var wr = 5e4, Tr = 0, Er = 16, Dr = [
|
|
1844
1847
|
[-1, 0],
|
|
1845
1848
|
[1, 0],
|
|
@@ -1995,8 +1998,7 @@ function jr(e, t, n) {
|
|
|
1995
1998
|
function Mr(e) {
|
|
1996
1999
|
return e.filter((t, n) => n === 0 || t.x !== e[n - 1].x || t.y !== e[n - 1].y);
|
|
1997
2000
|
}
|
|
1998
|
-
|
|
1999
|
-
//#region src/pathfinding/follow-path.ts
|
|
2001
|
+
// src/pathfinding/follow-path.ts
|
|
2000
2002
|
var $ = {
|
|
2001
2003
|
Waiting: 0,
|
|
2002
2004
|
Waypoint: 1,
|
|
@@ -2011,8 +2013,7 @@ function Nr(e, t, n, r, a) {
|
|
|
2011
2013
|
let c = e[2];
|
|
2012
2014
|
return c === I.Incomplete ? (wt(e), $.Waiting) : c === I.Found ? (a.x = i(e, 6), a.y = i(e, 7), $.Goal) : $.Stuck;
|
|
2013
2015
|
}
|
|
2014
|
-
|
|
2015
|
-
//#region src/pathfinding/path-blockers.ts
|
|
2016
|
+
// src/pathfinding/path-blockers.ts
|
|
2016
2017
|
var Pr = "pathBlockers", Fr = "pathGates";
|
|
2017
2018
|
function Ir(e = {}) {
|
|
2018
2019
|
let { gateCategories: t = 0, not: n, filter: r } = e, i = {
|
|
@@ -2069,8 +2070,7 @@ function zr(e) {
|
|
|
2069
2070
|
let t = Math.round(e / (Math.PI / 2)) * Math.PI / 2;
|
|
2070
2071
|
return Math.abs(e - t) < 1e-5 ? t : e;
|
|
2071
2072
|
}
|
|
2072
|
-
|
|
2073
|
-
//#region src/pathfinding/navigation-state.ts
|
|
2073
|
+
// src/pathfinding/navigation-state.ts
|
|
2074
2074
|
function Br(e, t, n, r = 0) {
|
|
2075
2075
|
return {
|
|
2076
2076
|
grid: new gr(e, t, n),
|
|
@@ -2127,8 +2127,7 @@ function Gr(e, t) {
|
|
|
2127
2127
|
function Kr(e, t, n) {
|
|
2128
2128
|
for (let [r, i] of e.gatedGrids) r & t && n(i);
|
|
2129
2129
|
}
|
|
2130
|
-
|
|
2131
|
-
//#region src/pathfinding/pathfinding-update.ts
|
|
2130
|
+
// src/pathfinding/pathfinding-update.ts
|
|
2132
2131
|
var qr = 16e3;
|
|
2133
2132
|
function Jr(e = {}) {
|
|
2134
2133
|
let t = e.search ?? new kr({ diagonal: !0 }), n = e.iterationBudget ?? 16e3, r = e.gateCategories ?? 0, a = (e, r, a) => {
|
|
@@ -2195,8 +2194,7 @@ function Zr(e, t, n) {
|
|
|
2195
2194
|
}
|
|
2196
2195
|
return !0;
|
|
2197
2196
|
}
|
|
2198
|
-
|
|
2199
|
-
//#region src/pathfinding/pathfinding-system.ts
|
|
2197
|
+
// src/pathfinding/pathfinding-system.ts
|
|
2200
2198
|
var Qr = class extends r {
|
|
2201
2199
|
iterationBudget;
|
|
2202
2200
|
constructor(e, t) {
|
|
@@ -2278,7 +2276,6 @@ var Qr = class extends r {
|
|
|
2278
2276
|
e.committedTicks = dr(this.world);
|
|
2279
2277
|
}
|
|
2280
2278
|
};
|
|
2281
|
-
//#endregion
|
|
2282
2279
|
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 };
|
|
2283
2280
|
|
|
2284
2281
|
//# sourceMappingURL=index.js.map
|