@skewedaspect/sage 0.11.0 → 0.12.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/sage.es.js CHANGED
@@ -68,7 +68,7 @@ var He = class {
68
68
  configurable: !0
69
69
  });
70
70
  }
71
- }, j = "0.11.0", Ue = class e {
71
+ }, j = "0.12.0", Ue = class e {
72
72
  canvas;
73
73
  renderEngine;
74
74
  managers;
@@ -403,7 +403,7 @@ var B = class e extends Te {
403
403
  }), n.loadMesh(n.scene, this.name, this.state).catch((e) => {
404
404
  n.logger.error(`Loading the mesh for ${this.name} (${this.id}) failed. The entity keeps its node and carries no mesh.`, e);
405
405
  }).then((e) => {
406
- e !== void 0 && (e.parent = s.node, Xe(n, this.name, this.id, e)), s.mesh = e;
406
+ e !== void 0 && s.node.isDisposed() && (e.dispose(), e = void 0), e !== void 0 && (e.parent = s.node, Xe(n, this.name, this.id, e)), s.mesh = e;
407
407
  let t = L.get(s);
408
408
  L.delete(s), t?.();
409
409
  })) : L.has(s) ? L.set(s, () => {
@@ -1431,7 +1431,12 @@ function Mt(e) {
1431
1431
  function Nt(e, t) {
1432
1432
  return Math.abs(e) > jt || Math.abs(t) > jt;
1433
1433
  }
1434
- var Pt = /* @__PURE__ */ new Set([
1434
+ function Pt(e, t) {
1435
+ let n = { ...e };
1436
+ for (let e of t) n[e] = !0;
1437
+ return n;
1438
+ }
1439
+ var Ft = /* @__PURE__ */ new Set([
1435
1440
  "button",
1436
1441
  "checkbox",
1437
1442
  "color",
@@ -1443,36 +1448,36 @@ var Pt = /* @__PURE__ */ new Set([
1443
1448
  "reset",
1444
1449
  "submit"
1445
1450
  ]);
1446
- function Ft(e) {
1451
+ function It(e) {
1447
1452
  if (!(e instanceof Element)) return !1;
1448
1453
  if (e instanceof HTMLTextAreaElement) return !0;
1449
- if (e instanceof HTMLInputElement) return !Pt.has(e.type);
1454
+ if (e instanceof HTMLInputElement) return !Ft.has(e.type);
1450
1455
  let t = e.closest("[contenteditable]");
1451
1456
  return t !== null && t.getAttribute("contenteditable") !== "false";
1452
1457
  }
1453
- var It = class {
1458
+ var Lt = class {
1454
1459
  actions = new gt();
1455
1460
  contexts;
1456
1461
  #e = {};
1457
1462
  #t = {};
1458
- #n = {
1463
+ #n = /* @__PURE__ */ new Set();
1464
+ #r = /* @__PURE__ */ new Set();
1465
+ #i = {
1459
1466
  x: 0,
1460
1467
  y: 0
1461
1468
  };
1462
- #r = {
1469
+ #a = {
1463
1470
  deltaX: 0,
1464
1471
  deltaY: 0,
1465
1472
  deltaZ: 0
1466
1473
  };
1467
- #i = {
1474
+ #o = {
1468
1475
  x: 0,
1469
1476
  y: 0
1470
1477
  };
1471
- #a = /* @__PURE__ */ new Map();
1472
- #o = /* @__PURE__ */ new Set();
1473
1478
  #s = /* @__PURE__ */ new Map();
1474
- #c;
1475
- #l;
1479
+ #c = /* @__PURE__ */ new Set();
1480
+ #l = /* @__PURE__ */ new Map();
1476
1481
  #u;
1477
1482
  #d;
1478
1483
  #f;
@@ -1481,9 +1486,12 @@ var It = class {
1481
1486
  #h;
1482
1487
  #g;
1483
1488
  #_;
1489
+ #v;
1490
+ #y;
1491
+ #b;
1484
1492
  constructor(e) {
1485
- this.contexts = new ht(e), this.#f = (e) => {
1486
- Ft(e.composedPath()[0]) || (this.#v("keyboard", "key", e.code) && e.preventDefault(), this.#e[e.code] = !0, this.#E("keyboard"), this.#k({
1493
+ this.contexts = new ht(e), this.#m = (e) => {
1494
+ It(e.composedPath()[0]) || (this.#x("keyboard", "key", e.code) && e.preventDefault(), this.#e[e.code] = !0, this.#n.add(e.code), this.#A("keyboard"), this.#N({
1487
1495
  device: {
1488
1496
  type: "keyboard",
1489
1497
  index: 0
@@ -1492,12 +1500,12 @@ var It = class {
1492
1500
  sourceKey: e.code,
1493
1501
  value: !0
1494
1502
  }));
1495
- }, this.#p = (e) => {
1503
+ }, this.#h = (e) => {
1496
1504
  this.#e[e.code] = !1;
1497
- }, this.#m = (e) => {
1505
+ }, this.#g = (e) => {
1498
1506
  if (e.pointerType !== "mouse") return;
1499
1507
  let t = String(e.button);
1500
- this.#v("mouse", "button", t) && e.preventDefault(), this.#t[t] = !0, this.#E("mouse"), this.#k({
1508
+ this.#x("mouse", "button", t) && e.preventDefault(), this.#t[t] = !0, this.#r.add(t), this.#A("mouse"), this.#N({
1501
1509
  device: {
1502
1510
  type: "mouse",
1503
1511
  index: 0
@@ -1506,22 +1514,25 @@ var It = class {
1506
1514
  sourceKey: t,
1507
1515
  value: !0
1508
1516
  });
1509
- }, this.#h = (e) => {
1510
- e.pointerType === "mouse" && (this.#t[String(e.button)] = !1);
1511
- }, this.#g = (e) => {
1512
- e.pointerType === "mouse" && (this.#n.x = e.clientX, this.#n.y = e.clientY, this.#i.x += e.movementX, this.#i.y += e.movementY, Nt(e.movementX, e.movementY) && (this.#c = "mouse"));
1513
1517
  }, this.#_ = (e) => {
1514
- this.#v("mouse", "wheel") && e.preventDefault(), this.#r.deltaX += e.deltaX, this.#r.deltaY += e.deltaY, this.#r.deltaZ += e.deltaZ, (e.deltaX !== q || e.deltaY !== q || e.deltaZ !== q) && (this.#E("mouse"), this.#O(e));
1515
- }, A() && (window.addEventListener("keydown", this.#f), window.addEventListener("keyup", this.#p), window.addEventListener("pointerdown", this.#m), window.addEventListener("pointerup", this.#h), window.addEventListener("pointermove", this.#g), window.addEventListener("wheel", this.#_, { passive: !1 }));
1518
+ e.pointerType === "mouse" && (this.#t[String(e.button)] = !1);
1519
+ }, this.#v = (e) => {
1520
+ e.pointerType === "mouse" && (this.#i.x = e.clientX, this.#i.y = e.clientY, this.#o.x += e.movementX, this.#o.y += e.movementY, Nt(e.movementX, e.movementY) && (this.#u = "mouse"));
1521
+ }, this.#y = (e) => {
1522
+ this.#x("mouse", "wheel") && e.preventDefault(), this.#a.deltaX += e.deltaX, this.#a.deltaY += e.deltaY, this.#a.deltaZ += e.deltaZ, (e.deltaX !== q || e.deltaY !== q || e.deltaZ !== q) && (this.#A("mouse"), this.#M(e));
1523
+ }, this.#b = () => {
1524
+ for (let e of Object.keys(this.#e)) this.#e[e] = !1;
1525
+ for (let e of Object.keys(this.#t)) this.#t[e] = !1;
1526
+ }, A() && (window.addEventListener("blur", this.#b), window.addEventListener("keydown", this.#m), window.addEventListener("keyup", this.#h), window.addEventListener("pointerdown", this.#g), window.addEventListener("pointerup", this.#_), window.addEventListener("pointermove", this.#v), window.addEventListener("wheel", this.#y, { passive: !1 }));
1516
1527
  }
1517
1528
  get lastActiveDeviceType() {
1518
- return this.#c;
1529
+ return this.#u;
1519
1530
  }
1520
1531
  get activeScheme() {
1521
- return this.#l;
1532
+ return this.#d;
1522
1533
  }
1523
1534
  deviceState(e, t) {
1524
- return this.#S(e, t);
1535
+ return this.#E(e, t);
1525
1536
  }
1526
1537
  bind(e) {
1527
1538
  let t = this.actions.get(e.action);
@@ -1530,8 +1541,8 @@ var It = class {
1530
1541
  return this.contexts.addBinding(n), n;
1531
1542
  }
1532
1543
  registerCapture(e) {
1533
- return this.#o.add(e), () => {
1534
- this.#o.delete(e);
1544
+ return this.#c.add(e), () => {
1545
+ this.#c.delete(e);
1535
1546
  };
1536
1547
  }
1537
1548
  getBindingsForAction(e, t, n) {
@@ -1543,15 +1554,15 @@ var It = class {
1543
1554
  return r;
1544
1555
  }
1545
1556
  routeCapturedInput(e) {
1546
- this.#C();
1557
+ this.#D();
1547
1558
  let t = /* @__PURE__ */ new Map();
1548
1559
  for (let n of this.contexts.list()) if (this.contexts.isLive(n)) {
1549
- let r = this.#S(n.device.type, n.device.index);
1550
- n.kind === "value" ? this.#y(t, n, r) : _t(n, r, e, K);
1560
+ let r = this.#T(n.device.type, n.device.index);
1561
+ n.kind === "value" ? this.#S(t, n, r) : _t(n, r, e, K);
1551
1562
  }
1552
- this.#b(t, e), this.#T(e), this.#D(e), this.#i.x = q, this.#i.y = q, this.#r.deltaX = q, this.#r.deltaY = q, this.#r.deltaZ = q;
1563
+ this.#C(t, e), this.#k(e), this.#j(e), this.#o.x = q, this.#o.y = q, this.#a.deltaX = q, this.#a.deltaY = q, this.#a.deltaZ = q, this.#n.clear(), this.#r.clear();
1553
1564
  }
1554
- #v(e, t, n) {
1565
+ #x(e, t, n) {
1555
1566
  for (let r of this.contexts.list()) if (r.preventDefault && this.contexts.isLive(r)) {
1556
1567
  let { device: i, sourceType: a, sourceKey: o } = r.input;
1557
1568
  if (i.type === e && a === t && (n === void 0 || o === n)) return !0;
@@ -1559,9 +1570,9 @@ var It = class {
1559
1570
  return !1;
1560
1571
  }
1561
1572
  async dispose() {
1562
- A() && (window.removeEventListener("keydown", this.#f), window.removeEventListener("keyup", this.#p), window.removeEventListener("pointerdown", this.#m), window.removeEventListener("pointerup", this.#h), window.removeEventListener("pointermove", this.#g), window.removeEventListener("wheel", this.#_));
1573
+ A() && (window.removeEventListener("blur", this.#b), window.removeEventListener("keydown", this.#m), window.removeEventListener("keyup", this.#h), window.removeEventListener("pointerdown", this.#g), window.removeEventListener("pointerup", this.#_), window.removeEventListener("pointermove", this.#v), window.removeEventListener("wheel", this.#y));
1563
1574
  }
1564
- #y(e, t, n) {
1575
+ #S(e, t, n) {
1565
1576
  let r = t.process(n);
1566
1577
  if (r === void 0) return;
1567
1578
  let i = Number(r.value), a = e.get(t.action.name);
@@ -1570,46 +1581,54 @@ var It = class {
1570
1581
  value: i
1571
1582
  }) : a.value += i;
1572
1583
  }
1573
- #b(e, t) {
1574
- for (let [t, n] of this.#s) e.has(t) || e.set(t, {
1584
+ #C(e, t) {
1585
+ for (let [t, n] of this.#l) e.has(t) || e.set(t, {
1575
1586
  action: n,
1576
1587
  value: 0
1577
1588
  });
1578
1589
  for (let [n, r] of e) {
1579
- let e = this.#x(r.action, r.value), i = e !== this.#x(r.action, q), a = this.#s.has(n);
1580
- i ? this.#s.set(n, r.action) : this.#s.delete(n), (i || a) && vt(r.action, e, t, K);
1590
+ let e = this.#w(r.action, r.value), i = e !== this.#w(r.action, q), a = this.#l.has(n);
1591
+ i ? this.#l.set(n, r.action) : this.#l.delete(n), (i || a) && vt(r.action, e, t, K);
1581
1592
  }
1582
1593
  }
1583
- #x(e, t) {
1594
+ #w(e, t) {
1584
1595
  return e.type === "analog" ? e.minValue !== void 0 && t < e.minValue ? e.minValue : e.maxValue !== void 0 && t > e.maxValue ? e.maxValue : t : t;
1585
1596
  }
1586
- #S(e, t) {
1597
+ #T(e, t) {
1598
+ return e === "keyboard" ? { keys: Pt(this.#e, this.#n) } : e === "mouse" ? {
1599
+ buttons: Pt(this.#t, this.#r),
1600
+ position: this.#i,
1601
+ wheel: this.#a,
1602
+ movement: this.#o
1603
+ } : this.#E(e, t);
1604
+ }
1605
+ #E(e, t) {
1587
1606
  if (e === "keyboard") return { keys: this.#e };
1588
1607
  if (e === "mouse") return {
1589
1608
  buttons: this.#t,
1590
- position: this.#n,
1591
- wheel: this.#r,
1592
- movement: this.#i
1609
+ position: this.#i,
1610
+ wheel: this.#a,
1611
+ movement: this.#o
1593
1612
  };
1594
- let n = this.#a.get(t);
1613
+ let n = this.#s.get(t);
1595
1614
  return n === void 0 ? {
1596
1615
  buttons: {},
1597
1616
  axes: {}
1598
1617
  } : n;
1599
1618
  }
1600
- #C() {
1619
+ #D() {
1601
1620
  if (typeof navigator > "u" || typeof navigator.getGamepads != "function") return;
1602
1621
  let e = navigator.getGamepads();
1603
1622
  for (let t = 0; t < e.length; t++) {
1604
1623
  let n = e[t];
1605
- n !== null && this.#w(t, n);
1624
+ n !== null && this.#O(t, n);
1606
1625
  }
1607
1626
  }
1608
- #w(e, t) {
1627
+ #O(e, t) {
1609
1628
  let n = {}, r = !1;
1610
1629
  for (let i = 0; i < t.buttons.length; i++) {
1611
1630
  let a = t.buttons[i].value, o = String(i);
1612
- n[o] = a, Mt(a) && (r = !0, this.#k({
1631
+ n[o] = a, Mt(a) && (r = !0, this.#N({
1613
1632
  device: {
1614
1633
  type: "gamepad",
1615
1634
  index: e
@@ -1622,7 +1641,7 @@ var It = class {
1622
1641
  let i = {};
1623
1642
  for (let n = 0; n < t.axes.length; n++) {
1624
1643
  let a = t.axes[n], o = String(n);
1625
- i[o] = a, Mt(a) && (r = !0, this.#k({
1644
+ i[o] = a, Mt(a) && (r = !0, this.#N({
1626
1645
  device: {
1627
1646
  type: "gamepad",
1628
1647
  index: e
@@ -1632,39 +1651,39 @@ var It = class {
1632
1651
  value: a
1633
1652
  }));
1634
1653
  }
1635
- this.#a.set(e, {
1654
+ this.#s.set(e, {
1636
1655
  buttons: n,
1637
1656
  axes: i
1638
- }), r && this.#E("gamepad");
1657
+ }), r && this.#A("gamepad");
1639
1658
  }
1640
- #T(e) {
1641
- if (this.#c === this.#u) return;
1642
- let t = this.#u;
1643
- this.#u = this.#c, this.#c !== void 0 && e.bus.emit({
1659
+ #k(e) {
1660
+ if (this.#u === this.#f) return;
1661
+ let t = this.#f;
1662
+ this.#f = this.#u, this.#u !== void 0 && e.bus.emit({
1644
1663
  type: "input:deviceChanged",
1645
1664
  senderID: K,
1646
1665
  payload: {
1647
- deviceType: this.#c,
1666
+ deviceType: this.#u,
1648
1667
  previousDeviceType: t
1649
1668
  }
1650
1669
  });
1651
1670
  }
1652
- #E(e) {
1653
- this.#c = e, this.#l = G(e);
1671
+ #A(e) {
1672
+ this.#u = e, this.#d = G(e);
1654
1673
  }
1655
- #D(e) {
1656
- if (this.#l === this.#d) return;
1657
- let t = this.#d;
1658
- this.#d = this.#l, this.#l !== void 0 && e.bus.emit({
1674
+ #j(e) {
1675
+ if (this.#d === this.#p) return;
1676
+ let t = this.#p;
1677
+ this.#p = this.#d, this.#d !== void 0 && e.bus.emit({
1659
1678
  type: "input:schemeChanged",
1660
1679
  senderID: K,
1661
1680
  payload: {
1662
- scheme: this.#l,
1681
+ scheme: this.#d,
1663
1682
  previousScheme: t
1664
1683
  }
1665
1684
  });
1666
1685
  }
1667
- #O(e) {
1686
+ #M(e) {
1668
1687
  let t = [
1669
1688
  {
1670
1689
  sourceKey: "deltaY",
@@ -1679,7 +1698,7 @@ var It = class {
1679
1698
  value: e.deltaZ
1680
1699
  }
1681
1700
  ];
1682
- for (let e of t) e.value !== q && this.#k({
1701
+ for (let e of t) e.value !== q && this.#N({
1683
1702
  device: {
1684
1703
  type: "mouse",
1685
1704
  index: 0
@@ -1689,21 +1708,21 @@ var It = class {
1689
1708
  value: e.value
1690
1709
  });
1691
1710
  }
1692
- #k(e) {
1693
- for (let t of this.#o) t.feed(e);
1711
+ #N(e) {
1712
+ for (let t of this.#c) t.feed(e);
1694
1713
  }
1695
- }, Lt = {
1714
+ }, Rt = {
1696
1715
  hable: g.TONEMAPPING_STANDARD,
1697
1716
  reinhard: g.TONEMAPPING_STANDARD,
1698
1717
  hejidawson: g.TONEMAPPING_STANDARD,
1699
1718
  photographic: g.TONEMAPPING_STANDARD,
1700
1719
  aces: g.TONEMAPPING_ACES
1701
1720
  };
1702
- function Rt(e, t, n) {
1721
+ function zt(e, t, n) {
1703
1722
  if (!e.activeCamera) return;
1704
1723
  t.volumetric && n.warn("Volumetric lighting is recognized and applied by neither backend. Ignored.");
1705
1724
  let r = new c("sage-default", !0, e, e.cameras);
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) {
1725
+ 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 = Rt[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) {
1707
1726
  let n = new fe("sage-ssao", e, {
1708
1727
  ssaoRatio: .5,
1709
1728
  blurRatio: 1
@@ -1713,11 +1732,11 @@ function Rt(e, t, n) {
1713
1732
  }
1714
1733
  //#endregion
1715
1734
  //#region src/handlers/postProcessing.ts
1716
- async function zt(e, t, n) {
1735
+ async function Bt(e, t, n) {
1717
1736
  if (t.renderer === "frameGraph") {
1718
1737
  let { applyFrameGraphPostProcessing: r } = await import("./postProcessingFrameGraph-Dx3e6D33.js");
1719
1738
  await r(e, t, n);
1720
- } else Rt(e, t, n);
1739
+ } else zt(e, t, n);
1721
1740
  }
1722
1741
  //#endregion
1723
1742
  //#region src/utils/bounds.ts
@@ -1730,22 +1749,22 @@ function J(e) {
1730
1749
  }
1731
1750
  //#endregion
1732
1751
  //#region src/handlers/collider.ts
1733
- var Y = 1, Bt = [
1752
+ var Y = 1, Vt = [
1734
1753
  "box",
1735
1754
  "sphere",
1736
1755
  "mesh",
1737
1756
  "none"
1738
1757
  ];
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.`);
1758
+ function Ht(e, t, n) {
1759
+ for (let e of Vt) if (t === e) return e;
1760
+ n.warn(`Unusable collider on "${e.name}": ${JSON.stringify(t)}. The collider property takes ${Vt.join(", ")}. Building nothing.`);
1742
1761
  }
1743
- function Ht(e, t) {
1762
+ function Ut(e, t) {
1744
1763
  let n = e.metadata?.collider_mass;
1745
1764
  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;
1746
1765
  }
1747
- function Ut(e, t) {
1748
- let n = Ht(e, t), r = e.metadata?.collider_motion;
1766
+ function Wt(e, t) {
1767
+ let n = Ut(e, t), r = e.metadata?.collider_motion;
1749
1768
  return r === "dynamic" ? {
1750
1769
  type: S.DYNAMIC,
1751
1770
  mass: n
@@ -1757,10 +1776,10 @@ function Ut(e, t) {
1757
1776
  mass: n
1758
1777
  });
1759
1778
  }
1760
- function Wt(e) {
1779
+ function Gt(e) {
1761
1780
  return e instanceof y && e.getTotalVertices() > 0;
1762
1781
  }
1763
- function Gt(e) {
1782
+ function Kt(e) {
1764
1783
  for (let t of e.getChildMeshes(!1)) if (t.getTotalVertices() > 0) return !0;
1765
1784
  return !1;
1766
1785
  }
@@ -1777,35 +1796,35 @@ function X(e, t, n, r) {
1777
1796
  let o = new x(e, t, a, e.getScene());
1778
1797
  o.body.setMotionType(n.type), n.type === S.ANIMATED && o.body.setPrestepType(C.TELEPORT);
1779
1798
  }
1780
- function Kt(e, t, n) {
1781
- if (Wt(e)) {
1799
+ function qt(e, t, n) {
1800
+ if (Gt(e)) {
1782
1801
  X(e, t, n, void 0);
1783
1802
  return;
1784
1803
  }
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.`);
1804
+ if (!Kt(e)) throw Error(`Cannot build a collider on "${e.name}": it has neither a mesh nor anything under it to size a body from.`);
1786
1805
  X(e, t, n, J(e));
1787
1806
  }
1788
- function qt(e, t) {
1807
+ function Jt(e, t) {
1789
1808
  let n = e;
1790
1809
  for (let t of e.getChildMeshes(!1)) if (t.metadata?.collider_mesh === !0 && t instanceof y) {
1791
1810
  t.isVisible = !1, n = t;
1792
1811
  break;
1793
1812
  }
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.`);
1813
+ if (!Gt(n)) throw Error(`Cannot build a "mesh" collider on "${n.name}": a triangle mesh reads vertices, and this node has none of its own.`);
1795
1814
  X(n, w.MESH, t, void 0);
1796
1815
  }
1797
- function Jt(e) {
1816
+ function Yt(e) {
1798
1817
  e.registerPropertyHandler("collider", (e, t, n, r) => {
1799
1818
  if (!n.scene) throw Error("Scene not available for collider handler");
1800
- let i = Vt(e, t, r.logger);
1819
+ let i = Ht(e, t, r.logger);
1801
1820
  if (i === void 0 || i === "none") return;
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);
1821
+ let a = Wt(e, r.logger);
1822
+ i === "mesh" ? Jt(e, a) : i === "sphere" ? qt(e, w.SPHERE, a) : qt(e, w.BOX, a);
1804
1823
  });
1805
1824
  }
1806
1825
  //#endregion
1807
1826
  //#region src/handlers/lod.ts
1808
- function Yt(e) {
1827
+ function Xt(e) {
1809
1828
  let t = [];
1810
1829
  for (let n of e.split(",")) {
1811
1830
  let e = parseFloat(n.trim());
@@ -1813,10 +1832,10 @@ function Yt(e) {
1813
1832
  }
1814
1833
  return t;
1815
1834
  }
1816
- function Xt(e) {
1835
+ function Zt(e) {
1817
1836
  e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
1818
1837
  if (!(e instanceof y)) return;
1819
- let i = Yt(String(t));
1838
+ let i = Xt(String(t));
1820
1839
  if (i.length === 0) {
1821
1840
  r.logger.warn(`Unusable lod_distances on "${e.name}": ${JSON.stringify(t)}. No level added.`);
1822
1841
  return;
@@ -1831,14 +1850,14 @@ function Xt(e) {
1831
1850
  }
1832
1851
  //#endregion
1833
1852
  //#region src/handlers/occlusion.ts
1834
- function Zt(e) {
1853
+ function Qt(e) {
1835
1854
  e.registerPropertyHandler("occlusion", (e, t, n, r) => {
1836
1855
  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".`));
1837
1856
  });
1838
1857
  }
1839
1858
  //#endregion
1840
1859
  //#region src/utils/metadata.ts
1841
- function Qt(e, t) {
1860
+ function $t(e, t) {
1842
1861
  let n = {}, r = `${t}_`;
1843
1862
  for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
1844
1863
  let e = t.slice(r.length);
@@ -1848,11 +1867,11 @@ function Qt(e, t) {
1848
1867
  }
1849
1868
  //#endregion
1850
1869
  //#region src/handlers/sound.ts
1851
- function $t(e) {
1870
+ function en(e) {
1852
1871
  e.registerPropertyHandler("sound", async (e, t, n, r) => {
1853
1872
  let i = t;
1854
1873
  if (!n.scene) throw Error("Scene not available for sound handler");
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;
1874
+ let a = $t(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;
1856
1875
  if (!f) {
1857
1876
  r.logger.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
1858
1877
  return;
@@ -1870,7 +1889,7 @@ function $t(e) {
1870
1889
  }
1871
1890
  //#endregion
1872
1891
  //#region src/handlers/trigger.ts
1873
- function en(e, n, r, i, a) {
1892
+ function tn(e, n, r, i, a) {
1874
1893
  let o = t.OnIntersectionExitTrigger;
1875
1894
  a === "enter" && (o = t.OnIntersectionEnterTrigger);
1876
1895
  let s = `trigger:${a}`;
@@ -1888,7 +1907,7 @@ function en(e, n, r, i, a) {
1888
1907
  });
1889
1908
  }));
1890
1909
  }
1891
- function tn(n) {
1910
+ function nn(n) {
1892
1911
  n.registerPropertyHandler("trigger", (n, r, i, a) => {
1893
1912
  let o = r, s = i.scene;
1894
1913
  if (!s) throw Error("Scene not available for trigger handler");
@@ -1902,7 +1921,7 @@ function tn(n) {
1902
1921
  if (e === n || e.metadata?.trigger) return;
1903
1922
  let t = [];
1904
1923
  for (let n of ["enter", "exit"]) {
1905
- let r = en(u, o, c, e, n);
1924
+ let r = tn(u, o, c, e, n);
1906
1925
  r && t.push(r);
1907
1926
  }
1908
1927
  let r = e.onDisposeObservable.add(() => {
@@ -1922,7 +1941,7 @@ function tn(n) {
1922
1941
  }
1923
1942
  //#endregion
1924
1943
  //#region src/handlers/visible.ts
1925
- function nn(t) {
1944
+ function rn(t) {
1926
1945
  t.registerPropertyHandler("visible", (t, n) => {
1927
1946
  if (!(t instanceof e)) return;
1928
1947
  let r = !0;
@@ -1931,7 +1950,7 @@ function nn(t) {
1931
1950
  }
1932
1951
  //#endregion
1933
1952
  //#region src/handlers/index.ts
1934
- var rn = [
1953
+ var an = [
1935
1954
  "collider",
1936
1955
  "lod_distances",
1937
1956
  "occlusion",
@@ -1939,12 +1958,12 @@ var rn = [
1939
1958
  "trigger",
1940
1959
  "visible"
1941
1960
  ];
1942
- function an(e) {
1943
- Jt(e), Xt(e), Zt(e), $t(e), tn(e), nn(e);
1961
+ function on(e) {
1962
+ Yt(e), Zt(e), Qt(e), en(e), nn(e), rn(e);
1944
1963
  }
1945
1964
  //#endregion
1946
1965
  //#region src/classes/level.ts
1947
- var on = class {
1966
+ var sn = class {
1948
1967
  name;
1949
1968
  _log;
1950
1969
  _context;
@@ -1974,6 +1993,10 @@ var on = class {
1974
1993
  $adoptSimulation(e) {
1975
1994
  this._simulation = e;
1976
1995
  }
1996
+ createScene() {
1997
+ let e = this._context.sceneEngine.createScene();
1998
+ return this._scene = e, e;
1999
+ }
1977
2000
  rebuildSimulation(e, t) {
1978
2001
  return this._simulation = this._context.rebuildSimulation(e, t), this._simulation;
1979
2002
  }
@@ -2044,7 +2067,7 @@ var on = class {
2044
2067
  async dispose() {
2045
2068
  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);
2046
2069
  }
2047
- }, sn = class {
2070
+ }, cn = class {
2048
2071
  _scene;
2049
2072
  _layers = /* @__PURE__ */ new Map();
2050
2073
  constructor(e, t) {
@@ -2088,7 +2111,7 @@ var on = class {
2088
2111
  n.length > 0 && e.layer.addSelection(n);
2089
2112
  }
2090
2113
  }
2091
- }, cn = class extends on {
2114
+ }, ln = class extends sn {
2092
2115
  _config;
2093
2116
  _spawnPoints = [];
2094
2117
  _entityNodes = [];
@@ -2114,14 +2137,14 @@ var on = class {
2114
2137
  return n;
2115
2138
  }
2116
2139
  async buildScene() {
2117
- let { sceneEngine: e, assetManager: t } = this.context;
2118
- this._config.preload && this._config.preload.length > 0 && (this.$emitProgress(2, "Preloading assets..."), await t.preload(this._config.preload));
2119
- let n = e.createScene();
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) {
2140
+ let { assetManager: e } = this.context;
2141
+ this._config.preload && this._config.preload.length > 0 && (this.$emitProgress(2, "Preloading assets..."), await e.preload(this._config.preload));
2142
+ let t = this.createScene();
2143
+ if (this.rebuildSimulation(t, this._config.meshSource), this._config.physics && (this.$emitProgress(5, "Initializing physics..."), await this._enablePhysics(t)), this._config.scene && (this.$emitProgress(10, "Loading scene file..."), await this._loadSceneFile(t)), this._config.environment && (this.$emitProgress(15, "Setting up environment..."), this._processEnvironment(t)), this._processCameras(t), this._processLights(t), this._setupClustering(t), this._config.postProcessing) {
2121
2144
  let e = this._config.postProcessing.renderer ?? "pipeline";
2122
- this._log.info(`Applying post-processing with ${e} renderer`), await zt(n, this._config.postProcessing, this._log);
2145
+ this._log.info(`Applying post-processing with ${e} renderer`), await Bt(t, this._config.postProcessing, this._log);
2123
2146
  }
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;
2147
+ return this.outlines = new cn(t, this._config.outlines), this.$emitProgress(50, "Processing scene properties..."), await this._processNodeProperties(t), 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()), t;
2125
2148
  }
2126
2149
  async _loadSceneFile(e) {
2127
2150
  let t = this._getScenePath();
@@ -2297,7 +2320,7 @@ var on = class {
2297
2320
  }
2298
2321
  _warnUnhandledProperties(e) {
2299
2322
  let t = e.metadata;
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.`);
2323
+ for (let n of an) 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.`);
2301
2324
  }
2302
2325
  async _processNodeMetadata(e) {
2303
2326
  if ("spawn" in e.metadata) {
@@ -2394,7 +2417,7 @@ var on = class {
2394
2417
  for (let e of this._levelSounds.values()) e.dispose();
2395
2418
  this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.dispose();
2396
2419
  }
2397
- }, ln = class {
2420
+ }, un = class {
2398
2421
  _bus;
2399
2422
  _gameEngine = null;
2400
2423
  _log;
@@ -2461,7 +2484,7 @@ var on = class {
2461
2484
  if (!n) throw Error(`Level class '${e.class}' is not registered.`);
2462
2485
  return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
2463
2486
  }
2464
- return this._log.debug(`Creating level '${e.name}' using GameLevel`), new cn(e, t);
2487
+ return this._log.debug(`Creating level '${e.name}' using GameLevel`), new ln(e, t);
2465
2488
  }
2466
2489
  registerLevelConfig(e) {
2467
2490
  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}`);
@@ -2481,6 +2504,9 @@ var on = class {
2481
2504
  getLevel(e) {
2482
2505
  return this._loadedLevels.get(e) || null;
2483
2506
  }
2507
+ async unregisterLevelConfig(e) {
2508
+ await this.unloadLevel(e), this._levelConfigs.delete(e) && this._log.info(`Unregistered level config: ${e}`);
2509
+ }
2484
2510
  getLevelConfig(e) {
2485
2511
  return this._levelConfigs.get(e) || null;
2486
2512
  }
@@ -2570,7 +2596,7 @@ var on = class {
2570
2596
  for (let e of this._loadedLevels.values()) await e.dispose();
2571
2597
  this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
2572
2598
  }
2573
- }, un = class {
2599
+ }, dn = class {
2574
2600
  #e;
2575
2601
  #t = /* @__PURE__ */ new Map();
2576
2602
  #n = !1;
@@ -2639,7 +2665,7 @@ var on = class {
2639
2665
  if (!t) throw Error(`AudioManager: no channel named "${e}" is declared.`);
2640
2666
  return t;
2641
2667
  }
2642
- }, dn = 2, fn = class {
2668
+ }, fn = 2, pn = class {
2643
2669
  #e;
2644
2670
  #t;
2645
2671
  #n;
@@ -2664,7 +2690,7 @@ var on = class {
2664
2690
  t[n] = r;
2665
2691
  }
2666
2692
  return {
2667
- saveFormatVersion: dn,
2693
+ saveFormatVersion: fn,
2668
2694
  engineVersion: this.#t,
2669
2695
  level: this.#e.currentLevel?.name ?? "",
2670
2696
  timestamp: this.#n(),
@@ -2673,7 +2699,7 @@ var on = class {
2673
2699
  };
2674
2700
  }
2675
2701
  async load(e) {
2676
- if (e.saveFormatVersion !== dn) throw Error(`The save format version "${e.saveFormatVersion}" is not one this engine knows how to load.`);
2702
+ if (e.saveFormatVersion !== fn) throw Error(`The save format version "${e.saveFormatVersion}" is not one this engine knows how to load.`);
2677
2703
  this.#a(), await this.#e.transition(e.level, { forRestore: !0 });
2678
2704
  let t = this.#o().buildFromSnapshot(e.snapshot);
2679
2705
  return this.#e.$bindSimulation(t), {
@@ -2693,7 +2719,7 @@ var on = class {
2693
2719
  if (e === null) throw Error("SimulationSaveManager: the engine holds no simulation.");
2694
2720
  return e;
2695
2721
  }
2696
- }, pn = class {
2722
+ }, mn = class {
2697
2723
  _viewer = null;
2698
2724
  _shown = /* @__PURE__ */ new Map();
2699
2725
  _materials = /* @__PURE__ */ new Map();
@@ -2732,21 +2758,21 @@ var on = class {
2732
2758
  };
2733
2759
  //#endregion
2734
2760
  //#region src/utils/graphics.ts
2735
- async function mn() {
2761
+ async function hn() {
2736
2762
  return Ve() ? be.IsSupportedAsync : !1;
2737
2763
  }
2738
- async function hn(e, t) {
2764
+ async function gn(e, t) {
2739
2765
  let n = new be(e, t);
2740
2766
  return await n.initAsync(), n;
2741
2767
  }
2742
- function gn(e, t) {
2768
+ function _n(e, t) {
2743
2769
  return new u(e, t.antialias, t.options, t.adaptToDeviceRatio);
2744
2770
  }
2745
- function _n(e) {
2771
+ function vn(e) {
2746
2772
  return new te(e);
2747
2773
  }
2748
- async function vn(e, t, n = !1, r = new H("Boot")) {
2749
- if (e === null) return r.debug("Using Null Engine"), _n(t);
2774
+ async function yn(e, t, n = !1, r = new H("Boot")) {
2775
+ if (e === null) return r.debug("Using Null Engine"), vn(t);
2750
2776
  if (n) {
2751
2777
  if ("options" in t) {
2752
2778
  let e = t;
@@ -2764,25 +2790,25 @@ async function vn(e, t, n = !1, r = new H("Boot")) {
2764
2790
  }
2765
2791
  let i = t.engine || "auto";
2766
2792
  if (i === "webgpu") {
2767
- if (await mn()) try {
2768
- return r.debug("Using forced WebGPU engine"), await hn(e, t);
2793
+ if (await hn()) try {
2794
+ return r.debug("Using forced WebGPU engine"), await gn(e, t);
2769
2795
  } catch (e) {
2770
2796
  throw r.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
2771
2797
  }
2772
2798
  throw Error("WebGPU was forced but is not available in this browser.");
2773
2799
  }
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);
2800
+ if (i === "webgl") return r.debug("Using forced WebGL engine"), _n(e, t);
2801
+ if (await hn()) try {
2802
+ return r.debug("Using WebGPU"), await gn(e, t);
2777
2803
  } catch (e) {
2778
2804
  r.warn("WebGPU initialization failed, falling back to WebGL:", e);
2779
2805
  }
2780
2806
  else r.warn("WebGPU not supported, falling back to WebGL.");
2781
- return r.debug("Using WebGL"), gn(e, t);
2807
+ return r.debug("Using WebGL"), _n(e, t);
2782
2808
  }
2783
2809
  //#endregion
2784
2810
  //#region src/utils/timer.ts
2785
- var yn = class {
2811
+ var bn = class {
2786
2812
  _nextId = 0;
2787
2813
  _delays = [];
2788
2814
  _intervals = [];
@@ -2846,17 +2872,17 @@ function Z(e) {
2846
2872
  }
2847
2873
  return e.simulation;
2848
2874
  }
2849
- function bn(e, t) {
2875
+ function xn(e, t) {
2850
2876
  return typeof e == "string" ? Z(t)?.getEntity(e) : e;
2851
2877
  }
2852
- function xn(e, t) {
2878
+ function Sn(e, t) {
2853
2879
  let n = t.managers.gameManager, r = t.managers.levelManager, i = [];
2854
2880
  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) {
2855
2881
  if (typeof n == "symbol") return;
2856
2882
  let r = Z(t)?.getEntity(n);
2857
2883
  return r || console.warn(`[sage] Entity not found: ${n}`), r;
2858
2884
  } })), e.expose("level", { get: () => r.currentLevel }), e.expose("scene", { get: () => r.currentLevel?.scene ?? null }), e.expose("tp", (e, n, r, i) => {
2859
- let a = bn(e, t);
2885
+ let a = xn(e, t);
2860
2886
  if (!a) {
2861
2887
  console.warn(`[sage] Entity not found: ${e}`);
2862
2888
  return;
@@ -2897,7 +2923,7 @@ function xn(e, t) {
2897
2923
  });
2898
2924
  return console.table(a), [...i];
2899
2925
  }), e.expose("inspect", (e) => {
2900
- let n = bn(e, t);
2926
+ let n = xn(e, t);
2901
2927
  if (!n) {
2902
2928
  console.warn(`[sage] Entity not found: ${e}`);
2903
2929
  return;
@@ -2930,7 +2956,7 @@ function xn(e, t) {
2930
2956
  }
2931
2957
  //#endregion
2932
2958
  //#region src/interfaces/logger.ts
2933
- var Sn = [
2959
+ var Cn = [
2934
2960
  "trace",
2935
2961
  "debug",
2936
2962
  "info",
@@ -2940,7 +2966,7 @@ var Sn = [
2940
2966
  ];
2941
2967
  //#endregion
2942
2968
  //#region src/entities/defineEntity.ts
2943
- function Cn(e, t) {
2969
+ function wn(e, t) {
2944
2970
  let n = t ?? {}, r = e.tags ?? [], i = n.tags ?? [];
2945
2971
  return {
2946
2972
  ...e.defaultState,
@@ -2948,13 +2974,13 @@ function Cn(e, t) {
2948
2974
  tags: [.../* @__PURE__ */ new Set([...r, ...i])]
2949
2975
  };
2950
2976
  }
2951
- function wn(e) {
2977
+ function Tn(e) {
2952
2978
  class t extends B {
2953
2979
  static behaviors = e.behaviors;
2954
2980
  static meshConfig = e.mesh;
2955
2981
  static actions = e.actions;
2956
2982
  static create(t, n, r, i) {
2957
- let a = Cn(e, r);
2983
+ let a = wn(e, r);
2958
2984
  return super.create(t, n, a, i);
2959
2985
  }
2960
2986
  }
@@ -2965,12 +2991,12 @@ function wn(e) {
2965
2991
  function Q(e) {
2966
2992
  return new i(e.r, e.g, e.b);
2967
2993
  }
2968
- function Tn(e, t, n) {
2994
+ function En(e, t, n) {
2969
2995
  let r = `Create${t.charAt(0).toUpperCase()}${t.slice(1)}`, i = b[r];
2970
2996
  if (typeof i != "function") throw Error(`No Babylon mesh builder provides the primitive shape "${t}".`);
2971
2997
  return i(t, n ?? {}, e);
2972
2998
  }
2973
- function En(e, t, n) {
2999
+ function Dn(e, t, n) {
2974
3000
  if (n.type === "pbr") {
2975
3001
  let r = new ne(`${t.name}-material`, e);
2976
3002
  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;
@@ -2979,19 +3005,19 @@ function En(e, t, n) {
2979
3005
  n.color !== void 0 && (r.diffuseColor = Q(n.color)), n.emissive !== void 0 && (r.emissiveColor = Q(n.emissive)), t.material = r;
2980
3006
  }
2981
3007
  }
2982
- async function Dn(e, t, n) {
3008
+ async function On(e, t, n) {
2983
3009
  let 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;
3010
+ return t.source.includes("#") ? (await n.load(t.source), r = n.clone(t.source, e)) : r = En(e, t.source, t.params), r.isVisible = t.visible ?? !0, t.material !== void 0 && Dn(e, r, t.material), r;
2985
3011
  }
2986
- function On(e, t) {
3012
+ function kn(e, t) {
2987
3013
  return async (n, r) => {
2988
3014
  let i = e[r]?.meshConfig;
2989
- if (i !== void 0) return Dn(n, i, t);
3015
+ if (i !== void 0) return On(n, i, t);
2990
3016
  };
2991
3017
  }
2992
3018
  //#endregion
2993
3019
  //#region src/behaviors/sound.ts
2994
- var kn = class extends k {
3020
+ var An = class extends k {
2995
3021
  static ops = ["play", "stop"];
2996
3022
  defaults = { sounds: {} };
2997
3023
  #e = /* @__PURE__ */ new Map();
@@ -3033,10 +3059,10 @@ var kn = class extends k {
3033
3059
  };
3034
3060
  //#endregion
3035
3061
  //#region src/behaviors/physicsBody.ts
3036
- function An(e) {
3062
+ function jn(e) {
3037
3063
  return e === "sphere" ? w.SPHERE : e === "cylinder" ? w.CYLINDER : e === "convex" ? w.CONVEX_HULL : e === "mesh" ? w.MESH : w.BOX;
3038
3064
  }
3039
- function jn(e, t) {
3065
+ function Mn(e, t) {
3040
3066
  let { extents: n, center: r } = t;
3041
3067
  return e === "sphere" ? {
3042
3068
  radius: Math.max(n.x, n.y, n.z) / 2,
@@ -3050,7 +3076,7 @@ function jn(e, t) {
3050
3076
  center: r
3051
3077
  };
3052
3078
  }
3053
- function Mn(e, t) {
3079
+ function Nn(e, t) {
3054
3080
  let { extents: n } = e;
3055
3081
  if (e.shape === "sphere") return new ce(O.Zero(), n.x / 2, t);
3056
3082
  if (e.shape === "cylinder") {
@@ -3062,17 +3088,17 @@ function Mn(e, t) {
3062
3088
  function $(e) {
3063
3089
  return e === "static" ? S.STATIC : e === "kinematic" ? S.ANIMATED : S.DYNAMIC;
3064
3090
  }
3065
- function Nn(e) {
3091
+ function Pn(e) {
3066
3092
  return e === S.STATIC ? "static" : e === S.ANIMATED ? "kinematic" : "dynamic";
3067
3093
  }
3068
- function Pn(e) {
3094
+ function Fn(e) {
3069
3095
  return e === "kinematic" ? C.ACTION : C.TELEPORT;
3070
3096
  }
3071
- function Fn(e) {
3097
+ function In(e) {
3072
3098
  for (let t of e.getChildMeshes(!1)) if (t.getTotalVertices() > 0) return !0;
3073
3099
  return !1;
3074
3100
  }
3075
- var In = class extends k {
3101
+ var Ln = class extends k {
3076
3102
  static ops = ["applyImpulse"];
3077
3103
  defaults = {
3078
3104
  shape: "box",
@@ -3133,13 +3159,13 @@ var In = class extends k {
3133
3159
  if (r === "convex" || r === "mesh") {
3134
3160
  let a = e.mesh;
3135
3161
  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.`);
3136
- return new x(n, An(r), {
3162
+ return new x(n, jn(r), {
3137
3163
  mass: i,
3138
3164
  mesh: a
3139
3165
  }, t);
3140
3166
  }
3141
- let a = jn(r, this.#s(e));
3142
- return new x(n, An(r), {
3167
+ let a = Mn(r, this.#s(e));
3168
+ return new x(n, jn(r), {
3143
3169
  mass: i,
3144
3170
  ...a
3145
3171
  }, t);
@@ -3153,13 +3179,13 @@ var In = class extends k {
3153
3179
  center: e.center.clone()
3154
3180
  };
3155
3181
  }
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.`);
3182
+ if (!In(e.node)) throw Error(`HavokPhysicsBodyBehavior: entity "${e.id}" has neither a mesh nor anything under its node to size a body from.`);
3157
3183
  return J(e.node);
3158
3184
  }
3159
3185
  #c(e) {
3160
3186
  let t = new oe(e);
3161
3187
  for (let n of this.state.parts) {
3162
- let r = Mn(n, e);
3188
+ let r = Nn(n, e);
3163
3189
  t.addChild(r, N(n.position), F(n.rotation)), this.#a.push(r);
3164
3190
  }
3165
3191
  return this.#a.push(t), t;
@@ -3194,7 +3220,7 @@ var In = class extends k {
3194
3220
  get: () => s,
3195
3221
  set: r
3196
3222
  }), this.computed("motion", {
3197
- get: () => this.#n ? Nn(this.#r) : Nn(this.#y().getMotionType()),
3223
+ get: () => this.#n ? Pn(this.#r) : Pn(this.#y().getMotionType()),
3198
3224
  set: (e) => {
3199
3225
  if (this.#n) {
3200
3226
  this.#r = $(e);
@@ -3232,7 +3258,7 @@ var In = class extends k {
3232
3258
  }
3233
3259
  #d(e, t) {
3234
3260
  let n = this.#y(), r = n.transformNode;
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));
3261
+ r.position = N(e), r.rotationQuaternion = F(t), !this.#n && (n.setPrestepType(Fn(Pn(n.getMotionType()))), this.#b().setPhysicsBodyTransformation(n, r), n.setPrestepType(C.DISABLED));
3236
3262
  }
3237
3263
  #f(e) {
3238
3264
  if (e !== this.#n) {
@@ -3285,12 +3311,12 @@ var In = class extends k {
3285
3311
  if (this.#t === void 0) throw Error(`HavokPhysicsBodyBehavior: entity "${this.entity.id}" has no physics plugin to answer for.`);
3286
3312
  return this.#t;
3287
3313
  }
3288
- }, Ln = new O(0, -1, 0), Rn = "standing";
3289
- function zn(e) {
3314
+ }, Rn = new O(0, -1, 0), zn = "standing";
3315
+ function Bn(e) {
3290
3316
  let t = Object.keys(e);
3291
3317
  return t.sort((t, n) => e[n].height - e[t].height), t;
3292
3318
  }
3293
- var Bn = class extends k {
3319
+ var Vn = class extends k {
3294
3320
  defaults = {
3295
3321
  moveX: 0,
3296
3322
  moveZ: 0,
@@ -3325,7 +3351,7 @@ var Bn = class extends k {
3325
3351
  z: 0
3326
3352
  },
3327
3353
  grounded: !1,
3328
- stance: Rn
3354
+ stance: zn
3329
3355
  };
3330
3356
  #e;
3331
3357
  #t;
@@ -3335,7 +3361,7 @@ var Bn = class extends k {
3335
3361
  #a = /* @__PURE__ */ new Map();
3336
3362
  #o = W();
3337
3363
  #s = !1;
3338
- #c = Rn;
3364
+ #c = zn;
3339
3365
  #l = !1;
3340
3366
  #u;
3341
3367
  #d = O.Zero();
@@ -3355,7 +3381,7 @@ var Bn = class extends k {
3355
3381
  onUpdate(e) {
3356
3382
  let t = this.#e;
3357
3383
  if (t === void 0) return;
3358
- let n = t.checkSupport(e, Ln);
3384
+ let n = t.checkSupport(e, Rn);
3359
3385
  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);
3360
3386
  let i = this.desiredVelocity(e, n);
3361
3387
  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());
@@ -3401,7 +3427,7 @@ var Bn = class extends k {
3401
3427
  this.#v(this.state.wantsStance);
3402
3428
  let e = this.#c;
3403
3429
  if (this.stanceFits(this.state.wantsStance)) e = this.state.wantsStance;
3404
- else for (let t of zn(this.state.stances)) if (this.#_(this.state.stances[t]) && this.stanceFits(t)) {
3430
+ else for (let t of Bn(this.state.stances)) if (this.#_(this.state.stances[t]) && this.stanceFits(t)) {
3405
3431
  e = t;
3406
3432
  break;
3407
3433
  }
@@ -3499,7 +3525,7 @@ var Bn = class extends k {
3499
3525
  return t;
3500
3526
  }
3501
3527
  #R() {
3502
- let e = zn(this.state.stances);
3528
+ let e = Bn(this.state.stances);
3503
3529
  if (e.length === 0) throw Error(`CharacterControllerBehavior: entity "${this.entity.id}" has no stances to be in, and a character is always in one.`);
3504
3530
  return e[0];
3505
3531
  }
@@ -3517,7 +3543,7 @@ var Bn = class extends k {
3517
3543
  if (this.#e === void 0) throw Error(`CharacterControllerBehavior: entity "${this.entity.id}" has no capsule to answer for.`);
3518
3544
  return this.#e;
3519
3545
  }
3520
- }, Vn = class {
3546
+ }, Hn = class {
3521
3547
  #e;
3522
3548
  #t;
3523
3549
  #n;
@@ -3545,24 +3571,24 @@ var Bn = class extends k {
3545
3571
  };
3546
3572
  //#endregion
3547
3573
  //#region src/input/configuration.ts
3548
- function Hn(e, t, n) {
3574
+ function Un(e, t, n) {
3549
3575
  return {
3550
3576
  actions: [...e],
3551
3577
  bindings: t.map((e) => e.toDefinition()),
3552
3578
  contexts: [...n]
3553
3579
  };
3554
3580
  }
3555
- function Un(e, t, n) {
3581
+ function Wn(e, t, n) {
3556
3582
  for (let n of e.actions) t.register(n);
3557
3583
  for (let t of e.contexts) n.registerContext(t.name, t.exclusive);
3558
3584
  return [...e.bindings];
3559
3585
  }
3560
3586
  //#endregion
3561
3587
  //#region src/sage.ts
3562
- async function Wn(e, t, n = {}) {
3588
+ async function Gn(e, t, n = {}) {
3563
3589
  let r = new U(n.logLevel || "debug"), i = r.getLogger("SAGE");
3564
3590
  i.info(`Initializing SAGE Game Engine v${j}...`), i.debug("Creating rendering engine...");
3565
- let a = await vn(e, {
3591
+ let a = await yn(e, {
3566
3592
  antialias: !0,
3567
3593
  adaptToDeviceRatio: !0,
3568
3594
  enableAllFeatures: !0,
@@ -3573,13 +3599,13 @@ async function Wn(e, t, n = {}) {
3573
3599
  i.debug("Creating scene engine...");
3574
3600
  let s = new dt(a, r, n.havokBinary);
3575
3601
  i.debug("Creating managers...");
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);
3602
+ let c = new pt(o, s, r), l = new un(o, r), u = new pn(l, j), d = new mt(a, o, l, r), f = new Lt(r);
3577
3603
  d.setInputManager(f);
3578
3604
  let p, m;
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));
3605
+ 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 dn(p, r), await m.initialize(n.audioChannels));
3580
3606
  let h = n.fixedStepDuration ?? 1 / 60, g = async () => void 0;
3581
3607
  i.debug("Creating collider debug manager...");
3582
- let _ = new pn(), ee = (e, n, i) => new ot({
3608
+ let _ = new mn(), ee = (e, n, i) => new ot({
3583
3609
  id: n,
3584
3610
  bus: o,
3585
3611
  fixedStepDuration: i?.fixedStepDuration ?? h,
@@ -3597,7 +3623,7 @@ async function Wn(e, t, n = {}) {
3597
3623
  typeof n.debug == "object" && n.debug.namespace !== void 0 && (e = n.debug.namespace), v = new He(e);
3598
3624
  }
3599
3625
  i.debug("Creating game timer...");
3600
- let y = new yn();
3626
+ let y = new bn();
3601
3627
  d.registerFrameCallback((e) => y.tick(e * 1e3)), i.info(`SAGE Game Engine v${j} initialized successfully.`);
3602
3628
  let b = new Ue(e, a, o, r, y, ee, {
3603
3629
  sceneEngine: s,
@@ -3616,9 +3642,9 @@ async function Wn(e, t, n = {}) {
3616
3642
  v?.expose(e, t);
3617
3643
  }
3618
3644
  });
3619
- return l.$setGameEngine(b), d.$setGameEngine(b), u.$setGameEngine(b), v && xn(v, b), b;
3645
+ return l.$setGameEngine(b), d.$setGameEngine(b), u.$setGameEngine(b), v && Sn(v, b), b;
3620
3646
  }
3621
3647
  //#endregion
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 };
3648
+ export { ht as ActionContextRegistry, gt as ActionRegistry, pt as AssetManager, lt as AudioEngine, dn as AudioManager, an as BUILT_IN_PROPERTIES, xe as Behavior, Vn as CharacterControllerBehavior, mn as ColliderDebugManager, at as ConsoleBackend, He as DebugConsole, Ot as DeltaBinding, Se as EventBus, Ue as GameEngine, we as GameEntity, ln as GameLevel, mt as GameManager, Ee as GameRandom, De as GameSimulation, bn as GameTimer, yt as GamepadReader, Ln as HavokPhysicsBodyBehavior, Hn as InputCapture, Lt as InputManager, bt as KeyboardReader, sn as Level, un as LevelManager, Cn as LogLevels, U as LoggingUtility, xt as MouseReader, ke as NamedBehavior, B as NodeEntity, ct as NodePool, ot as NodeSimulation, V as NullBackend, cn as OutlineManager, K as ROUTING_LOOP_SENDER_ID, H as SAGELogger, dt as SceneEngine, pn as SimulationSaveManager, An as SoundBehavior, je as StateMachineBehavior, Et as ToggleBinding, Tt as TriggerBinding, j as VERSION, Dt as ValueBinding, Bt as applyPostProcessing, kn as buildStandardMeshSource, J as computeHierarchyBounds, Gn as createGameEngine, Tn as defineEntity, Me as defineStates, _t as deliverAction, Ne as dilationLimit, Pe as drainPassLimit, Un as exportConfiguration, qe as getCanonicalTransform, Wn as importConfiguration, A as isBrowser, Fe as operationCallDepthLimit, st as poolSizeLimit, wt as readerFor, on as registerAllPropertyHandlers, Sn as registerBuiltins, Yt as registerColliderHandler, Zt as registerLodHandler, Qt as registerOcclusionHandler, en as registerSoundHandler, nn as registerTriggerHandler, rn as registerVisibleHandler, kt as resolveBinding, G as schemeOf, P as toQuatObject, F as toQuaternion, M as toVec3Object, N as toVector3 };
3623
3649
 
3624
3650
  //# sourceMappingURL=sage.es.js.map