@skewedaspect/sage 0.10.0 → 0.11.0
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/classes/gameEngine.d.ts +7 -2
- package/dist/interfaces/game.d.ts +2 -2
- package/dist/interfaces/level.d.ts +2 -0
- package/dist/managers/asset.d.ts +16 -1
- package/dist/sage.d.ts +1 -1
- package/dist/sage.es.js +164 -118
- package/dist/sage.es.js.map +1 -1
- package/package.json +2 -2
package/dist/sage.es.js
CHANGED
|
@@ -68,7 +68,7 @@ var He = class {
|
|
|
68
68
|
configurable: !0
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
}, j = "0.
|
|
71
|
+
}, j = "0.11.0", Ue = class e {
|
|
72
72
|
canvas;
|
|
73
73
|
renderEngine;
|
|
74
74
|
managers;
|
|
@@ -838,6 +838,7 @@ var dt = class {
|
|
|
838
838
|
_containers = /* @__PURE__ */ new Map();
|
|
839
839
|
_sourceMeshes = /* @__PURE__ */ new Map();
|
|
840
840
|
_pendingContainers = /* @__PURE__ */ new Map();
|
|
841
|
+
_sceneContainers = /* @__PURE__ */ new WeakMap();
|
|
841
842
|
constructor(e, t, n) {
|
|
842
843
|
this._bus = e, this._sceneEngine = t, this._log = n?.getLogger("AssetManager") ?? new H("AssetManager");
|
|
843
844
|
}
|
|
@@ -872,6 +873,18 @@ var dt = class {
|
|
|
872
873
|
this._pendingContainers.delete(e);
|
|
873
874
|
}
|
|
874
875
|
}
|
|
876
|
+
_containerForScene(e, t) {
|
|
877
|
+
let n = this._sceneContainers.get(t);
|
|
878
|
+
n || (n = /* @__PURE__ */ new Map(), this._sceneContainers.set(t, n));
|
|
879
|
+
let r = n.get(e);
|
|
880
|
+
if (r) return r;
|
|
881
|
+
let i = this._sceneEngine.loadModel(e, t);
|
|
882
|
+
n.set(e, i);
|
|
883
|
+
let a = n;
|
|
884
|
+
return i.catch(() => {
|
|
885
|
+
a.delete(e);
|
|
886
|
+
}), i;
|
|
887
|
+
}
|
|
875
888
|
_findMeshInContainer(e, t, n) {
|
|
876
889
|
let r = e.meshes.find((e) => e.name === t);
|
|
877
890
|
if (!r) {
|
|
@@ -907,6 +920,16 @@ var dt = class {
|
|
|
907
920
|
});
|
|
908
921
|
return r.metadata = null, r;
|
|
909
922
|
}
|
|
923
|
+
async instantiate(e, t) {
|
|
924
|
+
let { basePath: n, fragment: r } = this._parsePath(e);
|
|
925
|
+
if (r) throw Error(`Cannot instantiate '${e}': the fragment '${r}' is one mesh. clone() copies one mesh.`);
|
|
926
|
+
let i = (await this._containerForScene(n, t)).instantiateModelsToScene(void 0, !1, { doNotInstantiate: !0 });
|
|
927
|
+
for (let e of i.rootNodes) {
|
|
928
|
+
e.metadata = null;
|
|
929
|
+
for (let t of e.getDescendants()) t.metadata = null;
|
|
930
|
+
}
|
|
931
|
+
return i;
|
|
932
|
+
}
|
|
910
933
|
async preload(e) {
|
|
911
934
|
let t = e.length, n = [], r = 0, i = 0, a = async () => {
|
|
912
935
|
for (; r < e.length;) {
|
|
@@ -1408,7 +1431,26 @@ function Mt(e) {
|
|
|
1408
1431
|
function Nt(e, t) {
|
|
1409
1432
|
return Math.abs(e) > jt || Math.abs(t) > jt;
|
|
1410
1433
|
}
|
|
1411
|
-
var Pt =
|
|
1434
|
+
var Pt = /* @__PURE__ */ new Set([
|
|
1435
|
+
"button",
|
|
1436
|
+
"checkbox",
|
|
1437
|
+
"color",
|
|
1438
|
+
"file",
|
|
1439
|
+
"hidden",
|
|
1440
|
+
"image",
|
|
1441
|
+
"radio",
|
|
1442
|
+
"range",
|
|
1443
|
+
"reset",
|
|
1444
|
+
"submit"
|
|
1445
|
+
]);
|
|
1446
|
+
function Ft(e) {
|
|
1447
|
+
if (!(e instanceof Element)) return !1;
|
|
1448
|
+
if (e instanceof HTMLTextAreaElement) return !0;
|
|
1449
|
+
if (e instanceof HTMLInputElement) return !Pt.has(e.type);
|
|
1450
|
+
let t = e.closest("[contenteditable]");
|
|
1451
|
+
return t !== null && t.getAttribute("contenteditable") !== "false";
|
|
1452
|
+
}
|
|
1453
|
+
var It = class {
|
|
1412
1454
|
actions = new gt();
|
|
1413
1455
|
contexts;
|
|
1414
1456
|
#e = {};
|
|
@@ -1441,7 +1483,7 @@ var Pt = class {
|
|
|
1441
1483
|
#_;
|
|
1442
1484
|
constructor(e) {
|
|
1443
1485
|
this.contexts = new ht(e), this.#f = (e) => {
|
|
1444
|
-
this.#v("keyboard", "key", e.code) && e.preventDefault(), this.#e[e.code] = !0, this.#E("keyboard"), this.#k({
|
|
1486
|
+
Ft(e.composedPath()[0]) || (this.#v("keyboard", "key", e.code) && e.preventDefault(), this.#e[e.code] = !0, this.#E("keyboard"), this.#k({
|
|
1445
1487
|
device: {
|
|
1446
1488
|
type: "keyboard",
|
|
1447
1489
|
index: 0
|
|
@@ -1449,7 +1491,7 @@ var Pt = class {
|
|
|
1449
1491
|
sourceType: "key",
|
|
1450
1492
|
sourceKey: e.code,
|
|
1451
1493
|
value: !0
|
|
1452
|
-
});
|
|
1494
|
+
}));
|
|
1453
1495
|
}, this.#p = (e) => {
|
|
1454
1496
|
this.#e[e.code] = !1;
|
|
1455
1497
|
}, this.#m = (e) => {
|
|
@@ -1650,18 +1692,18 @@ var Pt = class {
|
|
|
1650
1692
|
#k(e) {
|
|
1651
1693
|
for (let t of this.#o) t.feed(e);
|
|
1652
1694
|
}
|
|
1653
|
-
},
|
|
1695
|
+
}, Lt = {
|
|
1654
1696
|
hable: g.TONEMAPPING_STANDARD,
|
|
1655
1697
|
reinhard: g.TONEMAPPING_STANDARD,
|
|
1656
1698
|
hejidawson: g.TONEMAPPING_STANDARD,
|
|
1657
1699
|
photographic: g.TONEMAPPING_STANDARD,
|
|
1658
1700
|
aces: g.TONEMAPPING_ACES
|
|
1659
1701
|
};
|
|
1660
|
-
function
|
|
1702
|
+
function Rt(e, t, n) {
|
|
1661
1703
|
if (!e.activeCamera) return;
|
|
1662
1704
|
t.volumetric && n.warn("Volumetric lighting is recognized and applied by neither backend. Ignored.");
|
|
1663
1705
|
let r = new c("sage-default", !0, e, e.cameras);
|
|
1664
|
-
if (t.bloom && (r.bloomEnabled = !0, t.bloom.weight !== void 0 && (r.bloomWeight = t.bloom.weight), t.bloom.threshold !== void 0 && (r.bloomThreshold = t.bloom.threshold), t.bloom.scale !== void 0 && (r.bloomScale = t.bloom.scale), t.bloom.kernel !== void 0 && (r.bloomKernel = t.bloom.kernel)), t.tonemap && (r.imageProcessingEnabled = !0, r.imageProcessing.toneMappingEnabled = !0, t.tonemap.operator && (r.imageProcessing.toneMappingType =
|
|
1706
|
+
if (t.bloom && (r.bloomEnabled = !0, t.bloom.weight !== void 0 && (r.bloomWeight = t.bloom.weight), t.bloom.threshold !== void 0 && (r.bloomThreshold = t.bloom.threshold), t.bloom.scale !== void 0 && (r.bloomScale = t.bloom.scale), t.bloom.kernel !== void 0 && (r.bloomKernel = t.bloom.kernel)), t.tonemap && (r.imageProcessingEnabled = !0, r.imageProcessing.toneMappingEnabled = !0, t.tonemap.operator && (r.imageProcessing.toneMappingType = Lt[t.tonemap.operator] ?? g.TONEMAPPING_STANDARD)), t.grain && (r.grainEnabled = !0, t.grain.intensity !== void 0 && (r.grain.intensity = t.grain.intensity), t.grain.animated !== void 0 && (r.grain.animated = t.grain.animated)), t.vignette && (r.imageProcessingEnabled = !0, r.imageProcessing.vignetteEnabled = !0, t.vignette.weight !== void 0 && (r.imageProcessing.vignetteWeight = t.vignette.weight), t.vignette.stretch !== void 0 && (r.imageProcessing.vignetteStretch = t.vignette.stretch), t.vignette.color && (r.imageProcessing.vignetteColor = new a(t.vignette.color.r, t.vignette.color.g, t.vignette.color.b, 1))), t.sharpen && (r.sharpenEnabled = !0, t.sharpen.edge !== void 0 && (r.sharpen.edgeAmount = t.sharpen.edge), t.sharpen.color !== void 0 && (r.sharpen.colorAmount = t.sharpen.color)), t.chromaticAberration && (r.chromaticAberrationEnabled = !0, t.chromaticAberration.amount !== void 0 && (r.chromaticAberration.aberrationAmount = t.chromaticAberration.amount)), t.ssao) {
|
|
1665
1707
|
let n = new fe("sage-ssao", e, {
|
|
1666
1708
|
ssaoRatio: .5,
|
|
1667
1709
|
blurRatio: 1
|
|
@@ -1671,11 +1713,11 @@ function It(e, t, n) {
|
|
|
1671
1713
|
}
|
|
1672
1714
|
//#endregion
|
|
1673
1715
|
//#region src/handlers/postProcessing.ts
|
|
1674
|
-
async function
|
|
1716
|
+
async function zt(e, t, n) {
|
|
1675
1717
|
if (t.renderer === "frameGraph") {
|
|
1676
1718
|
let { applyFrameGraphPostProcessing: r } = await import("./postProcessingFrameGraph-Dx3e6D33.js");
|
|
1677
1719
|
await r(e, t, n);
|
|
1678
|
-
} else
|
|
1720
|
+
} else Rt(e, t, n);
|
|
1679
1721
|
}
|
|
1680
1722
|
//#endregion
|
|
1681
1723
|
//#region src/utils/bounds.ts
|
|
@@ -1688,22 +1730,22 @@ function J(e) {
|
|
|
1688
1730
|
}
|
|
1689
1731
|
//#endregion
|
|
1690
1732
|
//#region src/handlers/collider.ts
|
|
1691
|
-
var Y = 1,
|
|
1733
|
+
var Y = 1, Bt = [
|
|
1692
1734
|
"box",
|
|
1693
1735
|
"sphere",
|
|
1694
1736
|
"mesh",
|
|
1695
1737
|
"none"
|
|
1696
1738
|
];
|
|
1697
|
-
function
|
|
1698
|
-
for (let e of
|
|
1699
|
-
n.warn(`Unusable collider on "${e.name}": ${JSON.stringify(t)}. The collider property takes ${
|
|
1739
|
+
function Vt(e, t, n) {
|
|
1740
|
+
for (let e of Bt) if (t === e) return e;
|
|
1741
|
+
n.warn(`Unusable collider on "${e.name}": ${JSON.stringify(t)}. The collider property takes ${Bt.join(", ")}. Building nothing.`);
|
|
1700
1742
|
}
|
|
1701
|
-
function
|
|
1743
|
+
function Ht(e, t) {
|
|
1702
1744
|
let n = e.metadata?.collider_mass;
|
|
1703
1745
|
return n == null ? Y : typeof n != "number" || !Number.isFinite(n) ? (t.warn(`Unusable collider_mass on ${e.name}: ${JSON.stringify(n)}. Using the default of ${Y}.`), Y) : n;
|
|
1704
1746
|
}
|
|
1705
|
-
function
|
|
1706
|
-
let n =
|
|
1747
|
+
function Ut(e, t) {
|
|
1748
|
+
let n = Ht(e, t), r = e.metadata?.collider_motion;
|
|
1707
1749
|
return r === "dynamic" ? {
|
|
1708
1750
|
type: S.DYNAMIC,
|
|
1709
1751
|
mass: n
|
|
@@ -1715,10 +1757,10 @@ function Vt(e, t) {
|
|
|
1715
1757
|
mass: n
|
|
1716
1758
|
});
|
|
1717
1759
|
}
|
|
1718
|
-
function
|
|
1760
|
+
function Wt(e) {
|
|
1719
1761
|
return e instanceof y && e.getTotalVertices() > 0;
|
|
1720
1762
|
}
|
|
1721
|
-
function
|
|
1763
|
+
function Gt(e) {
|
|
1722
1764
|
for (let t of e.getChildMeshes(!1)) if (t.getTotalVertices() > 0) return !0;
|
|
1723
1765
|
return !1;
|
|
1724
1766
|
}
|
|
@@ -1735,35 +1777,35 @@ function X(e, t, n, r) {
|
|
|
1735
1777
|
let o = new x(e, t, a, e.getScene());
|
|
1736
1778
|
o.body.setMotionType(n.type), n.type === S.ANIMATED && o.body.setPrestepType(C.TELEPORT);
|
|
1737
1779
|
}
|
|
1738
|
-
function
|
|
1739
|
-
if (
|
|
1780
|
+
function Kt(e, t, n) {
|
|
1781
|
+
if (Wt(e)) {
|
|
1740
1782
|
X(e, t, n, void 0);
|
|
1741
1783
|
return;
|
|
1742
1784
|
}
|
|
1743
|
-
if (!
|
|
1785
|
+
if (!Gt(e)) throw Error(`Cannot build a collider on "${e.name}": it has neither a mesh nor anything under it to size a body from.`);
|
|
1744
1786
|
X(e, t, n, J(e));
|
|
1745
1787
|
}
|
|
1746
|
-
function
|
|
1788
|
+
function qt(e, t) {
|
|
1747
1789
|
let n = e;
|
|
1748
1790
|
for (let t of e.getChildMeshes(!1)) if (t.metadata?.collider_mesh === !0 && t instanceof y) {
|
|
1749
1791
|
t.isVisible = !1, n = t;
|
|
1750
1792
|
break;
|
|
1751
1793
|
}
|
|
1752
|
-
if (!
|
|
1794
|
+
if (!Wt(n)) throw Error(`Cannot build a "mesh" collider on "${n.name}": a triangle mesh reads vertices, and this node has none of its own.`);
|
|
1753
1795
|
X(n, w.MESH, t, void 0);
|
|
1754
1796
|
}
|
|
1755
|
-
function
|
|
1797
|
+
function Jt(e) {
|
|
1756
1798
|
e.registerPropertyHandler("collider", (e, t, n, r) => {
|
|
1757
1799
|
if (!n.scene) throw Error("Scene not available for collider handler");
|
|
1758
|
-
let i =
|
|
1800
|
+
let i = Vt(e, t, r.logger);
|
|
1759
1801
|
if (i === void 0 || i === "none") return;
|
|
1760
|
-
let a =
|
|
1761
|
-
i === "mesh" ?
|
|
1802
|
+
let a = Ut(e, r.logger);
|
|
1803
|
+
i === "mesh" ? qt(e, a) : i === "sphere" ? Kt(e, w.SPHERE, a) : Kt(e, w.BOX, a);
|
|
1762
1804
|
});
|
|
1763
1805
|
}
|
|
1764
1806
|
//#endregion
|
|
1765
1807
|
//#region src/handlers/lod.ts
|
|
1766
|
-
function
|
|
1808
|
+
function Yt(e) {
|
|
1767
1809
|
let t = [];
|
|
1768
1810
|
for (let n of e.split(",")) {
|
|
1769
1811
|
let e = parseFloat(n.trim());
|
|
@@ -1771,10 +1813,10 @@ function qt(e) {
|
|
|
1771
1813
|
}
|
|
1772
1814
|
return t;
|
|
1773
1815
|
}
|
|
1774
|
-
function
|
|
1816
|
+
function Xt(e) {
|
|
1775
1817
|
e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
|
|
1776
1818
|
if (!(e instanceof y)) return;
|
|
1777
|
-
let i =
|
|
1819
|
+
let i = Yt(String(t));
|
|
1778
1820
|
if (i.length === 0) {
|
|
1779
1821
|
r.logger.warn(`Unusable lod_distances on "${e.name}": ${JSON.stringify(t)}. No level added.`);
|
|
1780
1822
|
return;
|
|
@@ -1789,14 +1831,14 @@ function Jt(e) {
|
|
|
1789
1831
|
}
|
|
1790
1832
|
//#endregion
|
|
1791
1833
|
//#region src/handlers/occlusion.ts
|
|
1792
|
-
function
|
|
1834
|
+
function Zt(e) {
|
|
1793
1835
|
e.registerPropertyHandler("occlusion", (e, t, n, r) => {
|
|
1794
1836
|
e instanceof y && (t === "optimistic" ? e.occlusionType = y.OCCLUSION_TYPE_OPTIMISTIC : t === "strict" ? e.occlusionType = y.OCCLUSION_TYPE_STRICT : r.logger.warn(`Unknown occlusion on "${e.name}": ${JSON.stringify(t)}. The occlusion property takes "optimistic" or "strict".`));
|
|
1795
1837
|
});
|
|
1796
1838
|
}
|
|
1797
1839
|
//#endregion
|
|
1798
1840
|
//#region src/utils/metadata.ts
|
|
1799
|
-
function
|
|
1841
|
+
function Qt(e, t) {
|
|
1800
1842
|
let n = {}, r = `${t}_`;
|
|
1801
1843
|
for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
|
|
1802
1844
|
let e = t.slice(r.length);
|
|
@@ -1806,11 +1848,11 @@ function Xt(e, t) {
|
|
|
1806
1848
|
}
|
|
1807
1849
|
//#endregion
|
|
1808
1850
|
//#region src/handlers/sound.ts
|
|
1809
|
-
function
|
|
1851
|
+
function $t(e) {
|
|
1810
1852
|
e.registerPropertyHandler("sound", async (e, t, n, r) => {
|
|
1811
1853
|
let i = t;
|
|
1812
1854
|
if (!n.scene) throw Error("Scene not available for sound handler");
|
|
1813
|
-
let a =
|
|
1855
|
+
let a = Qt(e.metadata, "sound"), o = a.volume ?? 1, s = a.loop ?? !0, c = a.spatial ?? !0, l = a.distance ?? 100, u = a.autoplay ?? !0, d = a.channel ?? "ambient", f = r.audioManager;
|
|
1814
1856
|
if (!f) {
|
|
1815
1857
|
r.logger.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
|
|
1816
1858
|
return;
|
|
@@ -1828,7 +1870,7 @@ function Zt(e) {
|
|
|
1828
1870
|
}
|
|
1829
1871
|
//#endregion
|
|
1830
1872
|
//#region src/handlers/trigger.ts
|
|
1831
|
-
function
|
|
1873
|
+
function en(e, n, r, i, a) {
|
|
1832
1874
|
let o = t.OnIntersectionExitTrigger;
|
|
1833
1875
|
a === "enter" && (o = t.OnIntersectionEnterTrigger);
|
|
1834
1876
|
let s = `trigger:${a}`;
|
|
@@ -1846,7 +1888,7 @@ function Qt(e, n, r, i, a) {
|
|
|
1846
1888
|
});
|
|
1847
1889
|
}));
|
|
1848
1890
|
}
|
|
1849
|
-
function
|
|
1891
|
+
function tn(n) {
|
|
1850
1892
|
n.registerPropertyHandler("trigger", (n, r, i, a) => {
|
|
1851
1893
|
let o = r, s = i.scene;
|
|
1852
1894
|
if (!s) throw Error("Scene not available for trigger handler");
|
|
@@ -1860,7 +1902,7 @@ function $t(n) {
|
|
|
1860
1902
|
if (e === n || e.metadata?.trigger) return;
|
|
1861
1903
|
let t = [];
|
|
1862
1904
|
for (let n of ["enter", "exit"]) {
|
|
1863
|
-
let r =
|
|
1905
|
+
let r = en(u, o, c, e, n);
|
|
1864
1906
|
r && t.push(r);
|
|
1865
1907
|
}
|
|
1866
1908
|
let r = e.onDisposeObservable.add(() => {
|
|
@@ -1880,7 +1922,7 @@ function $t(n) {
|
|
|
1880
1922
|
}
|
|
1881
1923
|
//#endregion
|
|
1882
1924
|
//#region src/handlers/visible.ts
|
|
1883
|
-
function
|
|
1925
|
+
function nn(t) {
|
|
1884
1926
|
t.registerPropertyHandler("visible", (t, n) => {
|
|
1885
1927
|
if (!(t instanceof e)) return;
|
|
1886
1928
|
let r = !0;
|
|
@@ -1889,7 +1931,7 @@ function en(t) {
|
|
|
1889
1931
|
}
|
|
1890
1932
|
//#endregion
|
|
1891
1933
|
//#region src/handlers/index.ts
|
|
1892
|
-
var
|
|
1934
|
+
var rn = [
|
|
1893
1935
|
"collider",
|
|
1894
1936
|
"lod_distances",
|
|
1895
1937
|
"occlusion",
|
|
@@ -1897,12 +1939,12 @@ var tn = [
|
|
|
1897
1939
|
"trigger",
|
|
1898
1940
|
"visible"
|
|
1899
1941
|
];
|
|
1900
|
-
function
|
|
1901
|
-
|
|
1942
|
+
function an(e) {
|
|
1943
|
+
Jt(e), Xt(e), Zt(e), $t(e), tn(e), nn(e);
|
|
1902
1944
|
}
|
|
1903
1945
|
//#endregion
|
|
1904
1946
|
//#region src/classes/level.ts
|
|
1905
|
-
var
|
|
1947
|
+
var on = class {
|
|
1906
1948
|
name;
|
|
1907
1949
|
_log;
|
|
1908
1950
|
_context;
|
|
@@ -2002,7 +2044,7 @@ var rn = class {
|
|
|
2002
2044
|
async dispose() {
|
|
2003
2045
|
this._scene &&= (this._log.info(`Disposing level: ${this.name}`), this.outlines &&= (this.outlines.dispose(), null), this.clusteredLights &&= (this.clusteredLights.dispose(), null), this._scene.dispose(), null);
|
|
2004
2046
|
}
|
|
2005
|
-
},
|
|
2047
|
+
}, sn = class {
|
|
2006
2048
|
_scene;
|
|
2007
2049
|
_layers = /* @__PURE__ */ new Map();
|
|
2008
2050
|
constructor(e, t) {
|
|
@@ -2046,7 +2088,7 @@ var rn = class {
|
|
|
2046
2088
|
n.length > 0 && e.layer.addSelection(n);
|
|
2047
2089
|
}
|
|
2048
2090
|
}
|
|
2049
|
-
},
|
|
2091
|
+
}, cn = class extends on {
|
|
2050
2092
|
_config;
|
|
2051
2093
|
_spawnPoints = [];
|
|
2052
2094
|
_entityNodes = [];
|
|
@@ -2077,9 +2119,9 @@ var rn = class {
|
|
|
2077
2119
|
let n = e.createScene();
|
|
2078
2120
|
if (this._scene = n, this.rebuildSimulation(n, this._config.meshSource), this._config.physics && (this.$emitProgress(5, "Initializing physics..."), await this._enablePhysics(n)), this._config.scene && (this.$emitProgress(10, "Loading scene file..."), await this._loadSceneFile(n)), this._config.environment && (this.$emitProgress(15, "Setting up environment..."), this._processEnvironment(n)), this._processCameras(n), this._processLights(n), this._setupClustering(n), this._config.postProcessing) {
|
|
2079
2121
|
let e = this._config.postProcessing.renderer ?? "pipeline";
|
|
2080
|
-
this._log.info(`Applying post-processing with ${e} renderer`), await
|
|
2122
|
+
this._log.info(`Applying post-processing with ${e} renderer`), await zt(n, this._config.postProcessing, this._log);
|
|
2081
2123
|
}
|
|
2082
|
-
return this.outlines = new
|
|
2124
|
+
return this.outlines = new sn(n, this._config.outlines), this.$emitProgress(50, "Processing scene properties..."), await this._processNodeProperties(n), this._forRestore || (this.$emitProgress(70, "Spawning entities..."), await this._processSpawnPoints(), this.$emitProgress(85, "Configuring entities..."), this._processEntityNodes()), this._config.sounds && (this.$emitProgress(95, "Loading sounds..."), await this._processLevelSounds()), n;
|
|
2083
2125
|
}
|
|
2084
2126
|
async _loadSceneFile(e) {
|
|
2085
2127
|
let t = this._getScenePath();
|
|
@@ -2255,7 +2297,7 @@ var rn = class {
|
|
|
2255
2297
|
}
|
|
2256
2298
|
_warnUnhandledProperties(e) {
|
|
2257
2299
|
let t = e.metadata;
|
|
2258
|
-
for (let n of
|
|
2300
|
+
for (let n of rn) n in t && !this.propertyHandlers.has(n) && this._log.warn(`Node '${e.name}' carries '${n}' and no handler is registered for it. Call registerAllPropertyHandlers on the level manager to install the built-in handlers.`);
|
|
2259
2301
|
}
|
|
2260
2302
|
async _processNodeMetadata(e) {
|
|
2261
2303
|
if ("spawn" in e.metadata) {
|
|
@@ -2352,7 +2394,7 @@ var rn = class {
|
|
|
2352
2394
|
for (let e of this._levelSounds.values()) e.dispose();
|
|
2353
2395
|
this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.dispose();
|
|
2354
2396
|
}
|
|
2355
|
-
},
|
|
2397
|
+
}, ln = class {
|
|
2356
2398
|
_bus;
|
|
2357
2399
|
_gameEngine = null;
|
|
2358
2400
|
_log;
|
|
@@ -2402,7 +2444,10 @@ var rn = class {
|
|
|
2402
2444
|
sceneEngine: t.engines.sceneEngine,
|
|
2403
2445
|
assetManager: t.managers.assetManager,
|
|
2404
2446
|
audioManager: t.managers.audioManager,
|
|
2405
|
-
rebuildSimulation: (n, r) => t.rebuildSimulation(n, e.name,
|
|
2447
|
+
rebuildSimulation: (n, r) => t.rebuildSimulation(n, e.name, {
|
|
2448
|
+
meshSource: r,
|
|
2449
|
+
fixedStepDuration: e.fixedStepDuration
|
|
2450
|
+
}),
|
|
2406
2451
|
canvas: t.canvas,
|
|
2407
2452
|
largeWorldRendering: t.largeWorldRendering,
|
|
2408
2453
|
propertyHandlers: this._propertyHandlers,
|
|
@@ -2416,7 +2461,7 @@ var rn = class {
|
|
|
2416
2461
|
if (!n) throw Error(`Level class '${e.class}' is not registered.`);
|
|
2417
2462
|
return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
|
|
2418
2463
|
}
|
|
2419
|
-
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new
|
|
2464
|
+
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new cn(e, t);
|
|
2420
2465
|
}
|
|
2421
2466
|
registerLevelConfig(e) {
|
|
2422
2467
|
this._levelConfigs.has(e.name) && this._log.warn(`Level config '${e.name}' is already registered. Overwriting.`), this._levelConfigs.set(e.name, e), this._log.info(`Registered level config: ${e.name}`);
|
|
@@ -2525,7 +2570,7 @@ var rn = class {
|
|
|
2525
2570
|
for (let e of this._loadedLevels.values()) await e.dispose();
|
|
2526
2571
|
this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
|
|
2527
2572
|
}
|
|
2528
|
-
},
|
|
2573
|
+
}, un = class {
|
|
2529
2574
|
#e;
|
|
2530
2575
|
#t = /* @__PURE__ */ new Map();
|
|
2531
2576
|
#n = !1;
|
|
@@ -2594,7 +2639,7 @@ var rn = class {
|
|
|
2594
2639
|
if (!t) throw Error(`AudioManager: no channel named "${e}" is declared.`);
|
|
2595
2640
|
return t;
|
|
2596
2641
|
}
|
|
2597
|
-
},
|
|
2642
|
+
}, dn = 2, fn = class {
|
|
2598
2643
|
#e;
|
|
2599
2644
|
#t;
|
|
2600
2645
|
#n;
|
|
@@ -2619,7 +2664,7 @@ var rn = class {
|
|
|
2619
2664
|
t[n] = r;
|
|
2620
2665
|
}
|
|
2621
2666
|
return {
|
|
2622
|
-
saveFormatVersion:
|
|
2667
|
+
saveFormatVersion: dn,
|
|
2623
2668
|
engineVersion: this.#t,
|
|
2624
2669
|
level: this.#e.currentLevel?.name ?? "",
|
|
2625
2670
|
timestamp: this.#n(),
|
|
@@ -2628,7 +2673,7 @@ var rn = class {
|
|
|
2628
2673
|
};
|
|
2629
2674
|
}
|
|
2630
2675
|
async load(e) {
|
|
2631
|
-
if (e.saveFormatVersion !==
|
|
2676
|
+
if (e.saveFormatVersion !== dn) throw Error(`The save format version "${e.saveFormatVersion}" is not one this engine knows how to load.`);
|
|
2632
2677
|
this.#a(), await this.#e.transition(e.level, { forRestore: !0 });
|
|
2633
2678
|
let t = this.#o().buildFromSnapshot(e.snapshot);
|
|
2634
2679
|
return this.#e.$bindSimulation(t), {
|
|
@@ -2648,7 +2693,7 @@ var rn = class {
|
|
|
2648
2693
|
if (e === null) throw Error("SimulationSaveManager: the engine holds no simulation.");
|
|
2649
2694
|
return e;
|
|
2650
2695
|
}
|
|
2651
|
-
},
|
|
2696
|
+
}, pn = class {
|
|
2652
2697
|
_viewer = null;
|
|
2653
2698
|
_shown = /* @__PURE__ */ new Map();
|
|
2654
2699
|
_materials = /* @__PURE__ */ new Map();
|
|
@@ -2687,21 +2732,21 @@ var rn = class {
|
|
|
2687
2732
|
};
|
|
2688
2733
|
//#endregion
|
|
2689
2734
|
//#region src/utils/graphics.ts
|
|
2690
|
-
async function
|
|
2735
|
+
async function mn() {
|
|
2691
2736
|
return Ve() ? be.IsSupportedAsync : !1;
|
|
2692
2737
|
}
|
|
2693
|
-
async function
|
|
2738
|
+
async function hn(e, t) {
|
|
2694
2739
|
let n = new be(e, t);
|
|
2695
2740
|
return await n.initAsync(), n;
|
|
2696
2741
|
}
|
|
2697
|
-
function
|
|
2742
|
+
function gn(e, t) {
|
|
2698
2743
|
return new u(e, t.antialias, t.options, t.adaptToDeviceRatio);
|
|
2699
2744
|
}
|
|
2700
|
-
function
|
|
2745
|
+
function _n(e) {
|
|
2701
2746
|
return new te(e);
|
|
2702
2747
|
}
|
|
2703
|
-
async function
|
|
2704
|
-
if (e === null) return r.debug("Using Null Engine"),
|
|
2748
|
+
async function vn(e, t, n = !1, r = new H("Boot")) {
|
|
2749
|
+
if (e === null) return r.debug("Using Null Engine"), _n(t);
|
|
2705
2750
|
if (n) {
|
|
2706
2751
|
if ("options" in t) {
|
|
2707
2752
|
let e = t;
|
|
@@ -2719,25 +2764,25 @@ async function gn(e, t, n = !1, r = new H("Boot")) {
|
|
|
2719
2764
|
}
|
|
2720
2765
|
let i = t.engine || "auto";
|
|
2721
2766
|
if (i === "webgpu") {
|
|
2722
|
-
if (await
|
|
2723
|
-
return r.debug("Using forced WebGPU engine"), await
|
|
2767
|
+
if (await mn()) try {
|
|
2768
|
+
return r.debug("Using forced WebGPU engine"), await hn(e, t);
|
|
2724
2769
|
} catch (e) {
|
|
2725
2770
|
throw r.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
|
|
2726
2771
|
}
|
|
2727
2772
|
throw Error("WebGPU was forced but is not available in this browser.");
|
|
2728
2773
|
}
|
|
2729
|
-
if (i === "webgl") return r.debug("Using forced WebGL engine"),
|
|
2730
|
-
if (await
|
|
2731
|
-
return r.debug("Using WebGPU"), await
|
|
2774
|
+
if (i === "webgl") return r.debug("Using forced WebGL engine"), gn(e, t);
|
|
2775
|
+
if (await mn()) try {
|
|
2776
|
+
return r.debug("Using WebGPU"), await hn(e, t);
|
|
2732
2777
|
} catch (e) {
|
|
2733
2778
|
r.warn("WebGPU initialization failed, falling back to WebGL:", e);
|
|
2734
2779
|
}
|
|
2735
2780
|
else r.warn("WebGPU not supported, falling back to WebGL.");
|
|
2736
|
-
return r.debug("Using WebGL"),
|
|
2781
|
+
return r.debug("Using WebGL"), gn(e, t);
|
|
2737
2782
|
}
|
|
2738
2783
|
//#endregion
|
|
2739
2784
|
//#region src/utils/timer.ts
|
|
2740
|
-
var
|
|
2785
|
+
var yn = class {
|
|
2741
2786
|
_nextId = 0;
|
|
2742
2787
|
_delays = [];
|
|
2743
2788
|
_intervals = [];
|
|
@@ -2801,17 +2846,17 @@ function Z(e) {
|
|
|
2801
2846
|
}
|
|
2802
2847
|
return e.simulation;
|
|
2803
2848
|
}
|
|
2804
|
-
function
|
|
2849
|
+
function bn(e, t) {
|
|
2805
2850
|
return typeof e == "string" ? Z(t)?.getEntity(e) : e;
|
|
2806
2851
|
}
|
|
2807
|
-
function
|
|
2852
|
+
function xn(e, t) {
|
|
2808
2853
|
let n = t.managers.gameManager, r = t.managers.levelManager, i = [];
|
|
2809
2854
|
e.expose("engine", t), e.expose("events", t.bus), e.expose("physics", { get: () => r.currentLevel?.scene?.getPhysicsEngine() ?? null }), e.expose("colliders", t.debug.colliders), e.expose("entities", new Proxy({}, { get(e, n) {
|
|
2810
2855
|
if (typeof n == "symbol") return;
|
|
2811
2856
|
let r = Z(t)?.getEntity(n);
|
|
2812
2857
|
return r || console.warn(`[sage] Entity not found: ${n}`), r;
|
|
2813
2858
|
} })), e.expose("level", { get: () => r.currentLevel }), e.expose("scene", { get: () => r.currentLevel?.scene ?? null }), e.expose("tp", (e, n, r, i) => {
|
|
2814
|
-
let a =
|
|
2859
|
+
let a = bn(e, t);
|
|
2815
2860
|
if (!a) {
|
|
2816
2861
|
console.warn(`[sage] Entity not found: ${e}`);
|
|
2817
2862
|
return;
|
|
@@ -2852,7 +2897,7 @@ function yn(e, t) {
|
|
|
2852
2897
|
});
|
|
2853
2898
|
return console.table(a), [...i];
|
|
2854
2899
|
}), e.expose("inspect", (e) => {
|
|
2855
|
-
let n =
|
|
2900
|
+
let n = bn(e, t);
|
|
2856
2901
|
if (!n) {
|
|
2857
2902
|
console.warn(`[sage] Entity not found: ${e}`);
|
|
2858
2903
|
return;
|
|
@@ -2885,7 +2930,7 @@ function yn(e, t) {
|
|
|
2885
2930
|
}
|
|
2886
2931
|
//#endregion
|
|
2887
2932
|
//#region src/interfaces/logger.ts
|
|
2888
|
-
var
|
|
2933
|
+
var Sn = [
|
|
2889
2934
|
"trace",
|
|
2890
2935
|
"debug",
|
|
2891
2936
|
"info",
|
|
@@ -2895,7 +2940,7 @@ var bn = [
|
|
|
2895
2940
|
];
|
|
2896
2941
|
//#endregion
|
|
2897
2942
|
//#region src/entities/defineEntity.ts
|
|
2898
|
-
function
|
|
2943
|
+
function Cn(e, t) {
|
|
2899
2944
|
let n = t ?? {}, r = e.tags ?? [], i = n.tags ?? [];
|
|
2900
2945
|
return {
|
|
2901
2946
|
...e.defaultState,
|
|
@@ -2903,13 +2948,13 @@ function xn(e, t) {
|
|
|
2903
2948
|
tags: [.../* @__PURE__ */ new Set([...r, ...i])]
|
|
2904
2949
|
};
|
|
2905
2950
|
}
|
|
2906
|
-
function
|
|
2951
|
+
function wn(e) {
|
|
2907
2952
|
class t extends B {
|
|
2908
2953
|
static behaviors = e.behaviors;
|
|
2909
2954
|
static meshConfig = e.mesh;
|
|
2910
2955
|
static actions = e.actions;
|
|
2911
2956
|
static create(t, n, r, i) {
|
|
2912
|
-
let a =
|
|
2957
|
+
let a = Cn(e, r);
|
|
2913
2958
|
return super.create(t, n, a, i);
|
|
2914
2959
|
}
|
|
2915
2960
|
}
|
|
@@ -2920,12 +2965,12 @@ function Sn(e) {
|
|
|
2920
2965
|
function Q(e) {
|
|
2921
2966
|
return new i(e.r, e.g, e.b);
|
|
2922
2967
|
}
|
|
2923
|
-
function
|
|
2968
|
+
function Tn(e, t, n) {
|
|
2924
2969
|
let r = `Create${t.charAt(0).toUpperCase()}${t.slice(1)}`, i = b[r];
|
|
2925
2970
|
if (typeof i != "function") throw Error(`No Babylon mesh builder provides the primitive shape "${t}".`);
|
|
2926
2971
|
return i(t, n ?? {}, e);
|
|
2927
2972
|
}
|
|
2928
|
-
function
|
|
2973
|
+
function En(e, t, n) {
|
|
2929
2974
|
if (n.type === "pbr") {
|
|
2930
2975
|
let r = new ne(`${t.name}-material`, e);
|
|
2931
2976
|
n.color !== void 0 && (r.albedoColor = Q(n.color)), n.emissive !== void 0 && (r.emissiveColor = Q(n.emissive)), n.metallic !== void 0 && (r.metallic = n.metallic), n.roughness !== void 0 && (r.roughness = n.roughness), t.material = r;
|
|
@@ -2934,19 +2979,19 @@ function wn(e, t, n) {
|
|
|
2934
2979
|
n.color !== void 0 && (r.diffuseColor = Q(n.color)), n.emissive !== void 0 && (r.emissiveColor = Q(n.emissive)), t.material = r;
|
|
2935
2980
|
}
|
|
2936
2981
|
}
|
|
2937
|
-
async function
|
|
2982
|
+
async function Dn(e, t, n) {
|
|
2938
2983
|
let r;
|
|
2939
|
-
return t.source.includes("#") ? (await n.load(t.source), r = n.clone(t.source, e)) : r =
|
|
2984
|
+
return t.source.includes("#") ? (await n.load(t.source), r = n.clone(t.source, e)) : r = Tn(e, t.source, t.params), r.isVisible = t.visible ?? !0, t.material !== void 0 && En(e, r, t.material), r;
|
|
2940
2985
|
}
|
|
2941
|
-
function
|
|
2986
|
+
function On(e, t) {
|
|
2942
2987
|
return async (n, r) => {
|
|
2943
2988
|
let i = e[r]?.meshConfig;
|
|
2944
|
-
if (i !== void 0) return
|
|
2989
|
+
if (i !== void 0) return Dn(n, i, t);
|
|
2945
2990
|
};
|
|
2946
2991
|
}
|
|
2947
2992
|
//#endregion
|
|
2948
2993
|
//#region src/behaviors/sound.ts
|
|
2949
|
-
var
|
|
2994
|
+
var kn = class extends k {
|
|
2950
2995
|
static ops = ["play", "stop"];
|
|
2951
2996
|
defaults = { sounds: {} };
|
|
2952
2997
|
#e = /* @__PURE__ */ new Map();
|
|
@@ -2988,10 +3033,10 @@ var Dn = class extends k {
|
|
|
2988
3033
|
};
|
|
2989
3034
|
//#endregion
|
|
2990
3035
|
//#region src/behaviors/physicsBody.ts
|
|
2991
|
-
function
|
|
3036
|
+
function An(e) {
|
|
2992
3037
|
return e === "sphere" ? w.SPHERE : e === "cylinder" ? w.CYLINDER : e === "convex" ? w.CONVEX_HULL : e === "mesh" ? w.MESH : w.BOX;
|
|
2993
3038
|
}
|
|
2994
|
-
function
|
|
3039
|
+
function jn(e, t) {
|
|
2995
3040
|
let { extents: n, center: r } = t;
|
|
2996
3041
|
return e === "sphere" ? {
|
|
2997
3042
|
radius: Math.max(n.x, n.y, n.z) / 2,
|
|
@@ -3005,7 +3050,7 @@ function kn(e, t) {
|
|
|
3005
3050
|
center: r
|
|
3006
3051
|
};
|
|
3007
3052
|
}
|
|
3008
|
-
function
|
|
3053
|
+
function Mn(e, t) {
|
|
3009
3054
|
let { extents: n } = e;
|
|
3010
3055
|
if (e.shape === "sphere") return new ce(O.Zero(), n.x / 2, t);
|
|
3011
3056
|
if (e.shape === "cylinder") {
|
|
@@ -3017,17 +3062,17 @@ function An(e, t) {
|
|
|
3017
3062
|
function $(e) {
|
|
3018
3063
|
return e === "static" ? S.STATIC : e === "kinematic" ? S.ANIMATED : S.DYNAMIC;
|
|
3019
3064
|
}
|
|
3020
|
-
function
|
|
3065
|
+
function Nn(e) {
|
|
3021
3066
|
return e === S.STATIC ? "static" : e === S.ANIMATED ? "kinematic" : "dynamic";
|
|
3022
3067
|
}
|
|
3023
|
-
function
|
|
3068
|
+
function Pn(e) {
|
|
3024
3069
|
return e === "kinematic" ? C.ACTION : C.TELEPORT;
|
|
3025
3070
|
}
|
|
3026
|
-
function
|
|
3071
|
+
function Fn(e) {
|
|
3027
3072
|
for (let t of e.getChildMeshes(!1)) if (t.getTotalVertices() > 0) return !0;
|
|
3028
3073
|
return !1;
|
|
3029
3074
|
}
|
|
3030
|
-
var
|
|
3075
|
+
var In = class extends k {
|
|
3031
3076
|
static ops = ["applyImpulse"];
|
|
3032
3077
|
defaults = {
|
|
3033
3078
|
shape: "box",
|
|
@@ -3088,13 +3133,13 @@ var Pn = class extends k {
|
|
|
3088
3133
|
if (r === "convex" || r === "mesh") {
|
|
3089
3134
|
let a = e.mesh;
|
|
3090
3135
|
if (!(a instanceof y) || a.getTotalVertices() === 0) throw Error(`HavokPhysicsBodyBehavior: entity "${e.id}" asked for a "${r}" body, which reads vertices, and it has no mesh geometry to read.`);
|
|
3091
|
-
return new x(n,
|
|
3136
|
+
return new x(n, An(r), {
|
|
3092
3137
|
mass: i,
|
|
3093
3138
|
mesh: a
|
|
3094
3139
|
}, t);
|
|
3095
3140
|
}
|
|
3096
|
-
let a =
|
|
3097
|
-
return new x(n,
|
|
3141
|
+
let a = jn(r, this.#s(e));
|
|
3142
|
+
return new x(n, An(r), {
|
|
3098
3143
|
mass: i,
|
|
3099
3144
|
...a
|
|
3100
3145
|
}, t);
|
|
@@ -3108,13 +3153,13 @@ var Pn = class extends k {
|
|
|
3108
3153
|
center: e.center.clone()
|
|
3109
3154
|
};
|
|
3110
3155
|
}
|
|
3111
|
-
if (!
|
|
3156
|
+
if (!Fn(e.node)) throw Error(`HavokPhysicsBodyBehavior: entity "${e.id}" has neither a mesh nor anything under its node to size a body from.`);
|
|
3112
3157
|
return J(e.node);
|
|
3113
3158
|
}
|
|
3114
3159
|
#c(e) {
|
|
3115
3160
|
let t = new oe(e);
|
|
3116
3161
|
for (let n of this.state.parts) {
|
|
3117
|
-
let r =
|
|
3162
|
+
let r = Mn(n, e);
|
|
3118
3163
|
t.addChild(r, N(n.position), F(n.rotation)), this.#a.push(r);
|
|
3119
3164
|
}
|
|
3120
3165
|
return this.#a.push(t), t;
|
|
@@ -3149,7 +3194,7 @@ var Pn = class extends k {
|
|
|
3149
3194
|
get: () => s,
|
|
3150
3195
|
set: r
|
|
3151
3196
|
}), this.computed("motion", {
|
|
3152
|
-
get: () => this.#n ?
|
|
3197
|
+
get: () => this.#n ? Nn(this.#r) : Nn(this.#y().getMotionType()),
|
|
3153
3198
|
set: (e) => {
|
|
3154
3199
|
if (this.#n) {
|
|
3155
3200
|
this.#r = $(e);
|
|
@@ -3187,7 +3232,7 @@ var Pn = class extends k {
|
|
|
3187
3232
|
}
|
|
3188
3233
|
#d(e, t) {
|
|
3189
3234
|
let n = this.#y(), r = n.transformNode;
|
|
3190
|
-
r.position = N(e), r.rotationQuaternion = F(t), !this.#n && (n.setPrestepType(
|
|
3235
|
+
r.position = N(e), r.rotationQuaternion = F(t), !this.#n && (n.setPrestepType(Pn(Nn(n.getMotionType()))), this.#b().setPhysicsBodyTransformation(n, r), n.setPrestepType(C.DISABLED));
|
|
3191
3236
|
}
|
|
3192
3237
|
#f(e) {
|
|
3193
3238
|
if (e !== this.#n) {
|
|
@@ -3240,12 +3285,12 @@ var Pn = class extends k {
|
|
|
3240
3285
|
if (this.#t === void 0) throw Error(`HavokPhysicsBodyBehavior: entity "${this.entity.id}" has no physics plugin to answer for.`);
|
|
3241
3286
|
return this.#t;
|
|
3242
3287
|
}
|
|
3243
|
-
},
|
|
3244
|
-
function
|
|
3288
|
+
}, Ln = new O(0, -1, 0), Rn = "standing";
|
|
3289
|
+
function zn(e) {
|
|
3245
3290
|
let t = Object.keys(e);
|
|
3246
3291
|
return t.sort((t, n) => e[n].height - e[t].height), t;
|
|
3247
3292
|
}
|
|
3248
|
-
var
|
|
3293
|
+
var Bn = class extends k {
|
|
3249
3294
|
defaults = {
|
|
3250
3295
|
moveX: 0,
|
|
3251
3296
|
moveZ: 0,
|
|
@@ -3280,7 +3325,7 @@ var Rn = class extends k {
|
|
|
3280
3325
|
z: 0
|
|
3281
3326
|
},
|
|
3282
3327
|
grounded: !1,
|
|
3283
|
-
stance:
|
|
3328
|
+
stance: Rn
|
|
3284
3329
|
};
|
|
3285
3330
|
#e;
|
|
3286
3331
|
#t;
|
|
@@ -3290,7 +3335,7 @@ var Rn = class extends k {
|
|
|
3290
3335
|
#a = /* @__PURE__ */ new Map();
|
|
3291
3336
|
#o = W();
|
|
3292
3337
|
#s = !1;
|
|
3293
|
-
#c =
|
|
3338
|
+
#c = Rn;
|
|
3294
3339
|
#l = !1;
|
|
3295
3340
|
#u;
|
|
3296
3341
|
#d = O.Zero();
|
|
@@ -3310,7 +3355,7 @@ var Rn = class extends k {
|
|
|
3310
3355
|
onUpdate(e) {
|
|
3311
3356
|
let t = this.#e;
|
|
3312
3357
|
if (t === void 0) return;
|
|
3313
|
-
let n = t.checkSupport(e,
|
|
3358
|
+
let n = t.checkSupport(e, Ln);
|
|
3314
3359
|
this.#l = n.supportedState === r.SUPPORTED, this.#l ? this.#h = 0 : this.#h += 1, this.#S(), this.#u = this.#O(), this.#E().y <= 0 && (this.#g = !1);
|
|
3315
3360
|
let i = this.desiredVelocity(e, n);
|
|
3316
3361
|
this.#w(n) && (this.#g = !0, i.y = this.state.jumpSpeed), this.#d = this.#D(), i.addInPlace(this.#d), t.setVelocity(i), t.integrate(e, n, this.#o), this.entity.node.setAbsolutePosition(this.#B(t.getPosition())), this.state.velocity = M(t.getVelocity());
|
|
@@ -3356,7 +3401,7 @@ var Rn = class extends k {
|
|
|
3356
3401
|
this.#v(this.state.wantsStance);
|
|
3357
3402
|
let e = this.#c;
|
|
3358
3403
|
if (this.stanceFits(this.state.wantsStance)) e = this.state.wantsStance;
|
|
3359
|
-
else for (let t of
|
|
3404
|
+
else for (let t of zn(this.state.stances)) if (this.#_(this.state.stances[t]) && this.stanceFits(t)) {
|
|
3360
3405
|
e = t;
|
|
3361
3406
|
break;
|
|
3362
3407
|
}
|
|
@@ -3454,7 +3499,7 @@ var Rn = class extends k {
|
|
|
3454
3499
|
return t;
|
|
3455
3500
|
}
|
|
3456
3501
|
#R() {
|
|
3457
|
-
let e =
|
|
3502
|
+
let e = zn(this.state.stances);
|
|
3458
3503
|
if (e.length === 0) throw Error(`CharacterControllerBehavior: entity "${this.entity.id}" has no stances to be in, and a character is always in one.`);
|
|
3459
3504
|
return e[0];
|
|
3460
3505
|
}
|
|
@@ -3472,7 +3517,7 @@ var Rn = class extends k {
|
|
|
3472
3517
|
if (this.#e === void 0) throw Error(`CharacterControllerBehavior: entity "${this.entity.id}" has no capsule to answer for.`);
|
|
3473
3518
|
return this.#e;
|
|
3474
3519
|
}
|
|
3475
|
-
},
|
|
3520
|
+
}, Vn = class {
|
|
3476
3521
|
#e;
|
|
3477
3522
|
#t;
|
|
3478
3523
|
#n;
|
|
@@ -3500,26 +3545,27 @@ var Rn = class extends k {
|
|
|
3500
3545
|
};
|
|
3501
3546
|
//#endregion
|
|
3502
3547
|
//#region src/input/configuration.ts
|
|
3503
|
-
function
|
|
3548
|
+
function Hn(e, t, n) {
|
|
3504
3549
|
return {
|
|
3505
3550
|
actions: [...e],
|
|
3506
3551
|
bindings: t.map((e) => e.toDefinition()),
|
|
3507
3552
|
contexts: [...n]
|
|
3508
3553
|
};
|
|
3509
3554
|
}
|
|
3510
|
-
function
|
|
3555
|
+
function Un(e, t, n) {
|
|
3511
3556
|
for (let n of e.actions) t.register(n);
|
|
3512
3557
|
for (let t of e.contexts) n.registerContext(t.name, t.exclusive);
|
|
3513
3558
|
return [...e.bindings];
|
|
3514
3559
|
}
|
|
3515
3560
|
//#endregion
|
|
3516
3561
|
//#region src/sage.ts
|
|
3517
|
-
async function
|
|
3562
|
+
async function Wn(e, t, n = {}) {
|
|
3518
3563
|
let r = new U(n.logLevel || "debug"), i = r.getLogger("SAGE");
|
|
3519
3564
|
i.info(`Initializing SAGE Game Engine v${j}...`), i.debug("Creating rendering engine...");
|
|
3520
|
-
let a = await
|
|
3565
|
+
let a = await vn(e, {
|
|
3521
3566
|
antialias: !0,
|
|
3522
3567
|
adaptToDeviceRatio: !0,
|
|
3568
|
+
enableAllFeatures: !0,
|
|
3523
3569
|
...n.renderOptions
|
|
3524
3570
|
}, n.largeWorldRendering ?? !1, i);
|
|
3525
3571
|
i.debug("Creating event bus...");
|
|
@@ -3527,20 +3573,20 @@ async function Hn(e, t, n = {}) {
|
|
|
3527
3573
|
i.debug("Creating scene engine...");
|
|
3528
3574
|
let s = new dt(a, r, n.havokBinary);
|
|
3529
3575
|
i.debug("Creating managers...");
|
|
3530
|
-
let c = new pt(o, s, r), l = new
|
|
3576
|
+
let c = new pt(o, s, r), l = new ln(o, r), u = new fn(l, j), d = new mt(a, o, l, r), f = new It(r);
|
|
3531
3577
|
d.setInputManager(f);
|
|
3532
3578
|
let p, m;
|
|
3533
|
-
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), p = new lt(r), await p.initialize(), i.debug("Creating audio manager..."), m = new
|
|
3579
|
+
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), p = new lt(r), await p.initialize(), i.debug("Creating audio manager..."), m = new un(p, r), await m.initialize(n.audioChannels));
|
|
3534
3580
|
let h = n.fixedStepDuration ?? 1 / 60, g = async () => void 0;
|
|
3535
3581
|
i.debug("Creating collider debug manager...");
|
|
3536
|
-
let _ = new
|
|
3582
|
+
let _ = new pn(), ee = (e, n, i) => new ot({
|
|
3537
3583
|
id: n,
|
|
3538
3584
|
bus: o,
|
|
3539
|
-
fixedStepDuration: h,
|
|
3585
|
+
fixedStepDuration: i?.fixedStepDuration ?? h,
|
|
3540
3586
|
entityClasses: t,
|
|
3541
3587
|
scene: e,
|
|
3542
3588
|
pool: new ct(),
|
|
3543
|
-
loadMesh: i ?? g,
|
|
3589
|
+
loadMesh: i?.meshSource ?? g,
|
|
3544
3590
|
audio: m,
|
|
3545
3591
|
colliders: _,
|
|
3546
3592
|
logger: r.getLogger("NodeSimulation")
|
|
@@ -3551,7 +3597,7 @@ async function Hn(e, t, n = {}) {
|
|
|
3551
3597
|
typeof n.debug == "object" && n.debug.namespace !== void 0 && (e = n.debug.namespace), v = new He(e);
|
|
3552
3598
|
}
|
|
3553
3599
|
i.debug("Creating game timer...");
|
|
3554
|
-
let y = new
|
|
3600
|
+
let y = new yn();
|
|
3555
3601
|
d.registerFrameCallback((e) => y.tick(e * 1e3)), i.info(`SAGE Game Engine v${j} initialized successfully.`);
|
|
3556
3602
|
let b = new Ue(e, a, o, r, y, ee, {
|
|
3557
3603
|
sceneEngine: s,
|
|
@@ -3570,9 +3616,9 @@ async function Hn(e, t, n = {}) {
|
|
|
3570
3616
|
v?.expose(e, t);
|
|
3571
3617
|
}
|
|
3572
3618
|
});
|
|
3573
|
-
return l.$setGameEngine(b), d.$setGameEngine(b), u.$setGameEngine(b), v &&
|
|
3619
|
+
return l.$setGameEngine(b), d.$setGameEngine(b), u.$setGameEngine(b), v && xn(v, b), b;
|
|
3574
3620
|
}
|
|
3575
3621
|
//#endregion
|
|
3576
|
-
export { ht as ActionContextRegistry, gt as ActionRegistry, pt as AssetManager, lt as AudioEngine,
|
|
3622
|
+
export { ht as ActionContextRegistry, gt as ActionRegistry, pt as AssetManager, lt as AudioEngine, un as AudioManager, rn as BUILT_IN_PROPERTIES, xe as Behavior, Bn as CharacterControllerBehavior, pn as ColliderDebugManager, at as ConsoleBackend, He as DebugConsole, Ot as DeltaBinding, Se as EventBus, Ue as GameEngine, we as GameEntity, cn as GameLevel, mt as GameManager, Ee as GameRandom, De as GameSimulation, yn as GameTimer, yt as GamepadReader, In as HavokPhysicsBodyBehavior, Vn as InputCapture, It as InputManager, bt as KeyboardReader, on as Level, ln as LevelManager, Sn as LogLevels, U as LoggingUtility, xt as MouseReader, ke as NamedBehavior, B as NodeEntity, ct as NodePool, ot as NodeSimulation, V as NullBackend, sn as OutlineManager, K as ROUTING_LOOP_SENDER_ID, H as SAGELogger, dt as SceneEngine, fn as SimulationSaveManager, kn as SoundBehavior, je as StateMachineBehavior, Et as ToggleBinding, Tt as TriggerBinding, j as VERSION, Dt as ValueBinding, zt as applyPostProcessing, On as buildStandardMeshSource, J as computeHierarchyBounds, Wn as createGameEngine, wn as defineEntity, Me as defineStates, _t as deliverAction, Ne as dilationLimit, Pe as drainPassLimit, Hn as exportConfiguration, qe as getCanonicalTransform, Un as importConfiguration, A as isBrowser, Fe as operationCallDepthLimit, st as poolSizeLimit, wt as readerFor, an as registerAllPropertyHandlers, xn as registerBuiltins, Jt as registerColliderHandler, Xt as registerLodHandler, Zt as registerOcclusionHandler, $t as registerSoundHandler, tn as registerTriggerHandler, nn as registerVisibleHandler, kt as resolveBinding, G as schemeOf, P as toQuatObject, F as toQuaternion, M as toVec3Object, N as toVector3 };
|
|
3577
3623
|
|
|
3578
3624
|
//# sourceMappingURL=sage.es.js.map
|