@skewedaspect/sage 0.5.0 → 0.5.1
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/bindings/toggle.d.ts +4 -4
- package/dist/classes/bindings/trigger.d.ts +4 -4
- package/dist/classes/bindings/value.d.ts +4 -4
- package/dist/classes/entity.d.ts +2 -2
- package/dist/classes/eventBus.d.ts +1 -1
- package/dist/classes/gameEngine.d.ts +8 -8
- package/dist/classes/input/gamepad.d.ts +1 -1
- package/dist/classes/input/keyboard.d.ts +1 -1
- package/dist/classes/input/mouse.d.ts +1 -1
- package/dist/classes/input/readers/gamepad.d.ts +1 -1
- package/dist/classes/input/readers/keyboard.d.ts +1 -1
- package/dist/classes/input/readers/mouse.d.ts +1 -1
- package/dist/classes/loggers/consoleBackend.d.ts +1 -1
- package/dist/classes/loggers/nullBackend.d.ts +1 -1
- package/dist/engines/scene.d.ts +2 -2
- package/dist/interfaces/binding.d.ts +4 -11
- package/dist/interfaces/entity.d.ts +5 -5
- package/dist/interfaces/game.d.ts +2 -2
- package/dist/managers/binding.d.ts +5 -5
- package/dist/managers/entity.d.ts +7 -7
- package/dist/managers/game.d.ts +5 -5
- package/dist/managers/input.d.ts +3 -3
- package/dist/managers/level.d.ts +1 -2
- package/dist/sage.d.ts +16 -14
- package/dist/sage.es.js +129 -71
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/dist/utils/graphics.d.ts +1 -1
- package/dist/utils/logger.d.ts +3 -3
- package/package.json +11 -7
- package/src/classes/bindings/toggle.ts +0 -261
- package/src/classes/bindings/trigger.ts +0 -211
- package/src/classes/bindings/value.ts +0 -227
- package/src/classes/entity.ts +0 -256
- package/src/classes/eventBus.ts +0 -259
- package/src/classes/gameEngine.ts +0 -125
- package/src/classes/input/gamepad.ts +0 -388
- package/src/classes/input/keyboard.ts +0 -189
- package/src/classes/input/mouse.ts +0 -276
- package/src/classes/input/readers/gamepad.ts +0 -179
- package/src/classes/input/readers/keyboard.ts +0 -123
- package/src/classes/input/readers/mouse.ts +0 -133
- package/src/classes/loggers/consoleBackend.ts +0 -135
- package/src/classes/loggers/nullBackend.ts +0 -51
- package/src/engines/scene.ts +0 -112
- package/src/images/sage_logo.svg +0 -172
- package/src/images/sage_logo_shape.svg +0 -146
- package/src/interfaces/action.ts +0 -30
- package/src/interfaces/binding.ts +0 -191
- package/src/interfaces/entity.ts +0 -21
- package/src/interfaces/game.ts +0 -44
- package/src/interfaces/input.ts +0 -221
- package/src/interfaces/logger.ts +0 -118
- package/src/managers/binding.ts +0 -729
- package/src/managers/entity.ts +0 -252
- package/src/managers/game.ts +0 -111
- package/src/managers/input.ts +0 -233
- package/src/managers/level.ts +0 -261
- package/src/sage.ts +0 -122
- package/src/types/global.d.ts +0 -11
- package/src/utils/capabilities.ts +0 -16
- package/src/utils/graphics.ts +0 -148
- package/src/utils/logger.ts +0 -225
- package/src/utils/physics.ts +0 -16
- package/src/utils/version.ts +0 -11
package/dist/sage.es.js
CHANGED
|
@@ -3,7 +3,7 @@ var k = (a, e, t) => e in a ? I(a, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var n = (a, e, t) => k(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { FreeCamera as V, Vector3 as b, HemisphericLight as G, MeshBuilder as D, PhysicsAggregate as E, PhysicsShapeType as C, Scene as L, NullEngine as B, WebGPUEngine as K, Engine as U, HavokPlugin as R } from "@babylonjs/core";
|
|
5
5
|
import T from "@babylonjs/havok";
|
|
6
|
-
const m = "0.5.
|
|
6
|
+
const m = "0.5.1";
|
|
7
7
|
class z {
|
|
8
8
|
/**
|
|
9
9
|
* Creates an instance of SkewedAspectGameEngine.
|
|
@@ -121,7 +121,12 @@ class W {
|
|
|
121
121
|
const o = performance.now() - i;
|
|
122
122
|
this.timers.delete(s);
|
|
123
123
|
const [r, c, h, u] = this.formatMessage(e, "timer");
|
|
124
|
-
console.info(
|
|
124
|
+
console.info(
|
|
125
|
+
`${r} Timer '${t}' completed in ${o.toFixed(2)}ms`,
|
|
126
|
+
c,
|
|
127
|
+
h,
|
|
128
|
+
u
|
|
129
|
+
);
|
|
125
130
|
} else
|
|
126
131
|
console.warn(`[${e}]: Timer '${t}' does not exist`);
|
|
127
132
|
}
|
|
@@ -142,7 +147,7 @@ class P {
|
|
|
142
147
|
timeEnd(e, t) {
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
|
-
class
|
|
150
|
+
class g {
|
|
146
151
|
constructor(e, t = "none", s = new P()) {
|
|
147
152
|
n(this, "category");
|
|
148
153
|
n(this, "backend");
|
|
@@ -218,7 +223,7 @@ class F {
|
|
|
218
223
|
*/
|
|
219
224
|
setBackend(e) {
|
|
220
225
|
this.backend = e, this.loggers.forEach((t) => {
|
|
221
|
-
t instanceof
|
|
226
|
+
t instanceof g && t.updateSettings(this.backend, this.level);
|
|
222
227
|
});
|
|
223
228
|
}
|
|
224
229
|
/**
|
|
@@ -228,7 +233,7 @@ class F {
|
|
|
228
233
|
*/
|
|
229
234
|
setLevel(e) {
|
|
230
235
|
this.level = e, this.loggers.forEach((t) => {
|
|
231
|
-
t instanceof
|
|
236
|
+
t instanceof g && t.updateSettings(this.backend, this.level);
|
|
232
237
|
});
|
|
233
238
|
}
|
|
234
239
|
/**
|
|
@@ -244,7 +249,7 @@ class F {
|
|
|
244
249
|
* @returns A Logger instance for the specified category
|
|
245
250
|
*/
|
|
246
251
|
getLogger(e) {
|
|
247
|
-
this.loggers.has(e) || this.loggers.set(e, new
|
|
252
|
+
this.loggers.has(e) || this.loggers.set(e, new g(e, this.level, this.backend));
|
|
248
253
|
const t = this.loggers.get(e);
|
|
249
254
|
if (t === void 0)
|
|
250
255
|
throw new Error(`Failed to create logger for category: ${e}`);
|
|
@@ -272,7 +277,7 @@ class O {
|
|
|
272
277
|
* Logger instance
|
|
273
278
|
*/
|
|
274
279
|
n(this, "_log");
|
|
275
|
-
this._log = (e == null ? void 0 : e.getLogger("EventBus")) || new
|
|
280
|
+
this._log = (e == null ? void 0 : e.getLogger("EventBus")) || new g("EventBus");
|
|
276
281
|
}
|
|
277
282
|
/**
|
|
278
283
|
* Subscribe with automatic detection:
|
|
@@ -321,7 +326,9 @@ class O {
|
|
|
321
326
|
let s;
|
|
322
327
|
if (typeof e == "string") {
|
|
323
328
|
const o = e.replace(/[-/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*");
|
|
324
|
-
s = new RegExp(`^${o}$`), this._log.debug(
|
|
329
|
+
s = new RegExp(`^${o}$`), this._log.debug(
|
|
330
|
+
`Adding pattern subscription for string: ${e}, regex: ${s.toString()}`
|
|
331
|
+
);
|
|
325
332
|
} else
|
|
326
333
|
s = e, this._log.debug(`Adding pattern subscription for regex: ${s.toString()}`);
|
|
327
334
|
const i = {
|
|
@@ -358,7 +365,7 @@ class N {
|
|
|
358
365
|
n(this, "_engine");
|
|
359
366
|
n(this, "_physics");
|
|
360
367
|
n(this, "_log");
|
|
361
|
-
this._engine = e, this._physics = t, this._log = (s == null ? void 0 : s.getLogger("SceneEngine")) || new
|
|
368
|
+
this._engine = e, this._physics = t, this._log = (s == null ? void 0 : s.getLogger("SceneEngine")) || new g("SceneEngine");
|
|
362
369
|
}
|
|
363
370
|
async _buildDemoScene(e, t) {
|
|
364
371
|
this._log.debug("Building demo scene..."), this._log.trace("Creating camera...");
|
|
@@ -369,7 +376,12 @@ class N {
|
|
|
369
376
|
const o = D.CreateSphere("sphere", { diameter: 2, segments: 32 }, e);
|
|
370
377
|
o.position.y = 4, this._log.trace("Creating ground...");
|
|
371
378
|
const r = D.CreateGround("ground", { width: 10, height: 10 }, e);
|
|
372
|
-
this._log.trace("Adding physics to sphere..."), new E(
|
|
379
|
+
this._log.trace("Adding physics to sphere..."), new E(
|
|
380
|
+
o,
|
|
381
|
+
C.SPHERE,
|
|
382
|
+
{ mass: 1, restitution: 0.75 },
|
|
383
|
+
e
|
|
384
|
+
), this._log.trace("Adding physics to ground..."), new E(r, C.BOX, { mass: 0 }, e), this._log.debug("Demo scene built successfully");
|
|
373
385
|
}
|
|
374
386
|
// TODO: This needs more logic to handle different scenes
|
|
375
387
|
async loadScene(e) {
|
|
@@ -449,8 +461,8 @@ class Y {
|
|
|
449
461
|
if (this.action.type === "analog") {
|
|
450
462
|
let h = typeof s == "number" ? s : s ? 1 : 0;
|
|
451
463
|
if (this.action.minValue !== void 0 || this.action.maxValue !== void 0) {
|
|
452
|
-
const u = this.action.minValue ?? 0,
|
|
453
|
-
h = u + h * (
|
|
464
|
+
const u = this.action.minValue ?? 0, _ = this.action.maxValue ?? 1;
|
|
465
|
+
h = u + h * (_ - u);
|
|
454
466
|
}
|
|
455
467
|
r = h;
|
|
456
468
|
} else
|
|
@@ -824,7 +836,10 @@ class x {
|
|
|
824
836
|
const [t, ...s] = e.split(":"), i = s.join(":");
|
|
825
837
|
if (!t || !i)
|
|
826
838
|
throw new Error(`Invalid mouse source format: ${e}`);
|
|
827
|
-
return new x(
|
|
839
|
+
return new x(
|
|
840
|
+
t,
|
|
841
|
+
i
|
|
842
|
+
);
|
|
828
843
|
}
|
|
829
844
|
/**
|
|
830
845
|
* Returns a JSON-serializable representation of this mouse value reader
|
|
@@ -902,7 +917,11 @@ class S {
|
|
|
902
917
|
const [s, i] = e.split(":");
|
|
903
918
|
if (!s || !i)
|
|
904
919
|
throw new Error(`Invalid gamepad source format: ${e}`);
|
|
905
|
-
return new S(
|
|
920
|
+
return new S(
|
|
921
|
+
s,
|
|
922
|
+
i,
|
|
923
|
+
t
|
|
924
|
+
);
|
|
906
925
|
}
|
|
907
926
|
/**
|
|
908
927
|
* Returns a JSON-serializable representation of this gamepad value reader
|
|
@@ -946,7 +965,7 @@ class j {
|
|
|
946
965
|
n(this, "_log");
|
|
947
966
|
this._eventBus = e, this._eventBus.subscribe("input:changed", (s) => {
|
|
948
967
|
s.payload && this.$handleInput(s.payload.device, s.payload.state);
|
|
949
|
-
}), this._log = (t == null ? void 0 : t.getLogger("BindingManager")) || new
|
|
968
|
+
}), this._log = (t == null ? void 0 : t.getLogger("BindingManager")) || new g("BindingManager"), this._log.debug("BindingManager initialized");
|
|
950
969
|
}
|
|
951
970
|
//------------------------------------------------------------------------------------------------------------------
|
|
952
971
|
// Private Methods
|
|
@@ -1003,20 +1022,35 @@ class j {
|
|
|
1003
1022
|
const { deviceID: s, ...i } = e.input;
|
|
1004
1023
|
switch (e.type) {
|
|
1005
1024
|
case "trigger":
|
|
1006
|
-
return new Y(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1025
|
+
return new Y(
|
|
1026
|
+
t,
|
|
1027
|
+
s,
|
|
1028
|
+
this._createInputSourceFromDefinition(i),
|
|
1029
|
+
{
|
|
1030
|
+
...e.options || {},
|
|
1031
|
+
context: e.context
|
|
1032
|
+
}
|
|
1033
|
+
);
|
|
1010
1034
|
case "toggle":
|
|
1011
|
-
return new H(
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1035
|
+
return new H(
|
|
1036
|
+
t,
|
|
1037
|
+
s,
|
|
1038
|
+
this._createInputSourceFromDefinition(i),
|
|
1039
|
+
{
|
|
1040
|
+
...e.options || {},
|
|
1041
|
+
context: e.context
|
|
1042
|
+
}
|
|
1043
|
+
);
|
|
1015
1044
|
case "value":
|
|
1016
|
-
return new X(
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1045
|
+
return new X(
|
|
1046
|
+
t,
|
|
1047
|
+
s,
|
|
1048
|
+
this._createInputSourceFromDefinition(i),
|
|
1049
|
+
{
|
|
1050
|
+
...e.options || {},
|
|
1051
|
+
context: e.context
|
|
1052
|
+
}
|
|
1053
|
+
);
|
|
1020
1054
|
default:
|
|
1021
1055
|
return this._log.error(`Binding type not implemented: ${e.type}`), null;
|
|
1022
1056
|
}
|
|
@@ -1031,18 +1065,28 @@ class j {
|
|
|
1031
1065
|
_createInputSourceFromDefinition(e) {
|
|
1032
1066
|
switch (e.type) {
|
|
1033
1067
|
case "keyboard":
|
|
1034
|
-
return new w(
|
|
1068
|
+
return new w(
|
|
1069
|
+
e.sourceKey,
|
|
1070
|
+
e.options
|
|
1071
|
+
);
|
|
1035
1072
|
case "mouse": {
|
|
1036
1073
|
const t = e.sourceType;
|
|
1037
1074
|
if (!(t === "button" || t === "position" || t === "wheel"))
|
|
1038
1075
|
throw new Error(`Invalid mouse source type: ${t}`);
|
|
1039
|
-
return new x(
|
|
1076
|
+
return new x(
|
|
1077
|
+
t,
|
|
1078
|
+
e.sourceKey
|
|
1079
|
+
);
|
|
1040
1080
|
}
|
|
1041
1081
|
case "gamepad": {
|
|
1042
1082
|
const t = e.sourceType;
|
|
1043
1083
|
if (!(t === "button" || t === "axis"))
|
|
1044
1084
|
throw new Error(`Invalid gamepad source type: ${t}`);
|
|
1045
|
-
return new S(
|
|
1085
|
+
return new S(
|
|
1086
|
+
t,
|
|
1087
|
+
e.sourceKey,
|
|
1088
|
+
e.options
|
|
1089
|
+
);
|
|
1046
1090
|
}
|
|
1047
1091
|
default:
|
|
1048
1092
|
throw new Error(`Unsupported input source type: ${e.type}`);
|
|
@@ -1278,7 +1322,7 @@ class Z {
|
|
|
1278
1322
|
n(this, "_currentScene", null);
|
|
1279
1323
|
n(this, "_log");
|
|
1280
1324
|
n(this, "started", !1);
|
|
1281
|
-
this._engine = e, this._sceneEngine = t, this._entityManager = s, this._inputManager = i, this._log = (o == null ? void 0 : o.getLogger("GameManager")) || new
|
|
1325
|
+
this._engine = e, this._sceneEngine = t, this._entityManager = s, this._inputManager = i, this._log = (o == null ? void 0 : o.getLogger("GameManager")) || new g("GameManager"), A() && window.addEventListener("resize", this._resizeHandler.bind(this));
|
|
1282
1326
|
}
|
|
1283
1327
|
_renderLoop() {
|
|
1284
1328
|
const e = this._engine.getDeltaTime();
|
|
@@ -1431,7 +1475,7 @@ class Q {
|
|
|
1431
1475
|
n(this, "bindingManager");
|
|
1432
1476
|
/** Logger instance */
|
|
1433
1477
|
n(this, "_log");
|
|
1434
|
-
this.eventBus = e, this.bindingManager = s, this._log = (t == null ? void 0 : t.getLogger("EntityManager")) || new
|
|
1478
|
+
this.eventBus = e, this.bindingManager = s, this._log = (t == null ? void 0 : t.getLogger("EntityManager")) || new g("EntityManager"), this._log.info("EntityManager initialized");
|
|
1435
1479
|
}
|
|
1436
1480
|
//------------------------------------------------------------------------------------------------------------------
|
|
1437
1481
|
// Private Methods
|
|
@@ -1442,19 +1486,23 @@ class Q {
|
|
|
1442
1486
|
* @param newAction - The action being registered
|
|
1443
1487
|
* @returns true if the actions are compatible, false if they have conflicting options
|
|
1444
1488
|
*/
|
|
1445
|
-
|
|
1489
|
+
_areActionsCompatible(e, t) {
|
|
1446
1490
|
return !(e.type !== t.type || e.type === "analog" && t.type === "analog" && (t.minValue !== void 0 && e.minValue !== t.minValue || t.maxValue !== void 0 && e.maxValue !== t.maxValue));
|
|
1447
1491
|
}
|
|
1448
1492
|
/**
|
|
1449
1493
|
* Registers actions defined in the entity definition with the binding manager
|
|
1450
1494
|
* @param entityDef - The entity definition containing actions to register
|
|
1451
1495
|
*/
|
|
1452
|
-
|
|
1496
|
+
_registerEntityActions(e) {
|
|
1453
1497
|
if (e.actions)
|
|
1454
1498
|
for (const t of e.actions)
|
|
1455
1499
|
try {
|
|
1456
1500
|
const s = this.bindingManager.getAction(t.name);
|
|
1457
|
-
s ? this.
|
|
1501
|
+
s ? this._areActionsCompatible(s, t) ? this._log.trace(
|
|
1502
|
+
`Action "${t.name}" already registered with compatible options, skipping registration`
|
|
1503
|
+
) : this._log.warn(
|
|
1504
|
+
`Action "${t.name}" already registered with different options. Entity "${e.type}" requires: ${JSON.stringify(t)}, but found: ${JSON.stringify(s)}`
|
|
1505
|
+
) : (this._log.debug(`Registering action "${t.name}" from entity type "${e.type}"`), this.bindingManager.registerAction(t));
|
|
1458
1506
|
} catch (s) {
|
|
1459
1507
|
this._log.debug(`Failed to register action "${t.name}": ${s instanceof Error ? s.message : String(s)}`);
|
|
1460
1508
|
}
|
|
@@ -1472,7 +1520,7 @@ class Q {
|
|
|
1472
1520
|
* @param entityDef - The definition of the entity.
|
|
1473
1521
|
*/
|
|
1474
1522
|
registerEntityDefinition(e) {
|
|
1475
|
-
this._log.debug(`Registering entity definition: ${e.type}`), this.
|
|
1523
|
+
this._log.debug(`Registering entity definition: ${e.type}`), this._registerEntityActions(e), this.entityDefinitions.set(e.type, e);
|
|
1476
1524
|
}
|
|
1477
1525
|
/**
|
|
1478
1526
|
* Creates a new entity of the given type.
|
|
@@ -1489,7 +1537,12 @@ class Q {
|
|
|
1489
1537
|
throw this._log.error(c), new Error(c);
|
|
1490
1538
|
}
|
|
1491
1539
|
this._log.trace(`Using entity definition with ${((r = s.behaviors) == null ? void 0 : r.length) || 0} behaviors`);
|
|
1492
|
-
const i = { ...s.defaultState, ...t }, o = new q(
|
|
1540
|
+
const i = { ...s.defaultState, ...t }, o = new q(
|
|
1541
|
+
s.type,
|
|
1542
|
+
this.eventBus,
|
|
1543
|
+
i,
|
|
1544
|
+
s.behaviors
|
|
1545
|
+
);
|
|
1493
1546
|
return this.entities.set(o.id, o), this._log.debug(`Entity created with ID: ${o.id}`), o;
|
|
1494
1547
|
}
|
|
1495
1548
|
/**
|
|
@@ -1908,22 +1961,22 @@ class se {
|
|
|
1908
1961
|
continue;
|
|
1909
1962
|
const o = this._buttonStates[s] || {}, r = this._axesStates[s] || {}, c = {};
|
|
1910
1963
|
let h = !1;
|
|
1911
|
-
t.buttons.forEach((d,
|
|
1912
|
-
const
|
|
1964
|
+
t.buttons.forEach((d, p) => {
|
|
1965
|
+
const l = `button-${p}`, f = {
|
|
1913
1966
|
pressed: d.pressed,
|
|
1914
1967
|
touched: d.touched,
|
|
1915
1968
|
value: d.value
|
|
1916
1969
|
};
|
|
1917
|
-
c[
|
|
1918
|
-
const y = o[
|
|
1970
|
+
c[l] = f;
|
|
1971
|
+
const y = o[l];
|
|
1919
1972
|
(!y || y.pressed !== f.pressed || y.touched !== f.touched || y.value !== f.value) && (h = !0);
|
|
1920
1973
|
});
|
|
1921
1974
|
const u = {};
|
|
1922
|
-
let
|
|
1923
|
-
if (t.axes.forEach((d,
|
|
1924
|
-
const
|
|
1925
|
-
u[
|
|
1926
|
-
}), this._buttonStates[s] = c, this._axesStates[s] = u, h ||
|
|
1975
|
+
let _ = !1;
|
|
1976
|
+
if (t.axes.forEach((d, p) => {
|
|
1977
|
+
const l = `axis-${p}`;
|
|
1978
|
+
u[l] = d, r[l] !== d && (_ = !0);
|
|
1979
|
+
}), this._buttonStates[s] = c, this._axesStates[s] = u, h || _) {
|
|
1927
1980
|
const d = {
|
|
1928
1981
|
type: "gamepad",
|
|
1929
1982
|
buttons: { ...c },
|
|
@@ -2027,7 +2080,7 @@ class ie {
|
|
|
2027
2080
|
n(this, "_gamepadRA");
|
|
2028
2081
|
/** Logger instance */
|
|
2029
2082
|
n(this, "_log");
|
|
2030
|
-
this._eventBus = e, this._log = (s == null ? void 0 : s.getLogger("UserInputManager")) || new
|
|
2083
|
+
this._eventBus = e, this._log = (s == null ? void 0 : s.getLogger("UserInputManager")) || new g("UserInputManager"), this._log.info("Initializing UserInputManager"), this._log.debug("Initializing input resource access classes"), this._keyboardRA = new ee(), this._mouseRA = new te(t), this._gamepadRA = new se(), this._log.debug("Registering input event callbacks"), this._keyboardRA.onDeviceConnected(this._publishDeviceConnected.bind(this)), this._keyboardRA.onInputChanged(this._publishInputChanged.bind(this)), this._mouseRA.onDeviceConnected(this._publishDeviceConnected.bind(this)), this._mouseRA.onInputChanged(this._publishInputChanged.bind(this)), this._gamepadRA.onDeviceConnected(this._publishDeviceConnected.bind(this)), this._gamepadRA.onDeviceDisconnected(this._publishDeviceDisconnected.bind(this)), this._gamepadRA.onInputChanged(this._publishInputChanged.bind(this)), this._log.info("UserInputManager initialized successfully");
|
|
2031
2084
|
}
|
|
2032
2085
|
//------------------------------------------------------------------------------------------------------------------
|
|
2033
2086
|
// Private methods
|
|
@@ -2140,7 +2193,9 @@ async function oe(a, e) {
|
|
|
2140
2193
|
try {
|
|
2141
2194
|
return console.debug("Using forced WebGPU engine"), await M(a, e);
|
|
2142
2195
|
} catch (s) {
|
|
2143
|
-
throw console.error("Forced WebGPU initialization failed:", s), new Error(
|
|
2196
|
+
throw console.error("Forced WebGPU initialization failed:", s), new Error(
|
|
2197
|
+
"Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility."
|
|
2198
|
+
);
|
|
2144
2199
|
}
|
|
2145
2200
|
else
|
|
2146
2201
|
throw new Error("WebGPU was forced but is not available in this browser.");
|
|
@@ -2168,37 +2223,40 @@ const de = ["keyboard", "mouse", "gamepad"], le = [
|
|
|
2168
2223
|
"error",
|
|
2169
2224
|
"none"
|
|
2170
2225
|
];
|
|
2171
|
-
async function ge(a, e = {}) {
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
const
|
|
2175
|
-
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2226
|
+
async function ge(a, e, t = {}) {
|
|
2227
|
+
const s = new F(t.logLevel || "debug"), i = s.getLogger("SAGE");
|
|
2228
|
+
i.info(`Initializing SAGE Game Engine v${m}...`), i.debug("Creating rendering engine...");
|
|
2229
|
+
const o = await oe(a, t.renderOptions || {});
|
|
2230
|
+
i.debug("Creating physics engine...");
|
|
2231
|
+
const r = await ae();
|
|
2232
|
+
i.debug("Creating event bus...");
|
|
2233
|
+
const c = new O(s);
|
|
2234
|
+
i.debug("Creating scene engine...");
|
|
2235
|
+
const h = new N(o, r, s);
|
|
2236
|
+
i.debug("Creating managers...");
|
|
2237
|
+
const u = new ie(c, a, s), _ = new j(c, s), d = new Q(c, s, _), p = new Z(o, h, d, u, s);
|
|
2238
|
+
i.info(`SAGE Game Engine v${m} initialized successfully.`), i.debug("Loading entities...");
|
|
2239
|
+
for (const l of e)
|
|
2240
|
+
d.registerEntityDefinition(l);
|
|
2241
|
+
if (i.debug("Registering default input bindings..."), t.bindings)
|
|
2242
|
+
for (const l of t.bindings)
|
|
2243
|
+
_.registerBinding(l);
|
|
2186
2244
|
return new z(
|
|
2187
2245
|
a,
|
|
2188
|
-
i,
|
|
2189
2246
|
o,
|
|
2190
2247
|
r,
|
|
2191
|
-
|
|
2248
|
+
c,
|
|
2249
|
+
s,
|
|
2192
2250
|
// Engines
|
|
2193
2251
|
{
|
|
2194
|
-
sceneEngine:
|
|
2252
|
+
sceneEngine: h
|
|
2195
2253
|
},
|
|
2196
2254
|
// Managers
|
|
2197
2255
|
{
|
|
2198
|
-
bindingManager:
|
|
2199
|
-
entityManager:
|
|
2200
|
-
gameManager:
|
|
2201
|
-
inputManager:
|
|
2256
|
+
bindingManager: _,
|
|
2257
|
+
entityManager: d,
|
|
2258
|
+
gameManager: p,
|
|
2259
|
+
inputManager: u
|
|
2202
2260
|
}
|
|
2203
2261
|
);
|
|
2204
2262
|
}
|
|
@@ -2210,7 +2268,7 @@ export {
|
|
|
2210
2268
|
le as LogLevels,
|
|
2211
2269
|
F as LoggingUtility,
|
|
2212
2270
|
P as NullBackend,
|
|
2213
|
-
|
|
2271
|
+
g as SAGELogger,
|
|
2214
2272
|
z as SkewedAspectGameEngine,
|
|
2215
2273
|
m as VERSION,
|
|
2216
2274
|
J as bindingTypes,
|