@skewedaspect/sage 0.9.2 → 0.9.4
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/LICENSE +1 -1
- package/dist/classes/debugConsole.d.ts +22 -0
- package/dist/classes/entity.d.ts +21 -0
- package/dist/classes/gameEngine.d.ts +12 -1
- package/dist/classes/gameLevel.d.ts +5 -0
- package/dist/debug/builtins.d.ts +6 -0
- package/dist/interfaces/entity.d.ts +5 -0
- package/dist/interfaces/game.d.ts +9 -0
- package/dist/interfaces/level.d.ts +5 -0
- package/dist/managers/colliderDebug.d.ts +16 -0
- package/dist/sage.d.ts +4 -0
- package/dist/sage.es.js +472 -207
- 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/entityProxy.d.ts +2 -0
- package/dist/utils/vectors.d.ts +8 -8
- package/package.json +1 -1
package/dist/sage.es.js
CHANGED
|
@@ -1,10 +1,65 @@
|
|
|
1
|
-
import { AbstractMesh as e, ActionManager as t, ArcRotateCamera as n, Color3 as r, Color4 as i, CreateAudioEngineAsync as a, CubeTexture as o, DefaultRenderingPipeline as s, DirectionalLight as c, Engine as l, ExecuteCodeAction as u, FreeCamera as d, HDRCubeTexture as f, HavokPlugin as p, HemisphericLight as m, ImageProcessingConfiguration as h, ImportMeshAsync as g, LoadAssetContainerAsync as _, Matrix as v, Mesh as y, MeshBuilder as b, NullEngine as x, PBRMaterial as
|
|
2
|
-
import { registerBuiltInLoaders as
|
|
3
|
-
import { GeospatialCamera as
|
|
4
|
-
import { ClusteredLightContainer as
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { AbstractMesh as e, ActionManager as t, ArcRotateCamera as n, Color3 as r, Color4 as i, CreateAudioEngineAsync as a, CubeTexture as o, DefaultRenderingPipeline as s, DirectionalLight as c, Engine as l, ExecuteCodeAction as u, FreeCamera as d, HDRCubeTexture as f, HavokPlugin as p, HemisphericLight as m, ImageProcessingConfiguration as h, ImportMeshAsync as g, LoadAssetContainerAsync as _, Matrix as v, Mesh as y, MeshBuilder as b, NullEngine as x, PBRMaterial as S, PhysicsAggregate as C, PhysicsShapeType as w, PointLight as ee, Quaternion as T, RectAreaLight as te, SSAO2RenderingPipeline as ne, Scene as re, SelectionOutlineLayer as ie, SoundState as ae, SpotLight as oe, StandardMaterial as E, Texture as se, TransformNode as D, UniversalCamera as ce, Vector3 as O, WebGPUEngine as le } from "@babylonjs/core";
|
|
2
|
+
import { registerBuiltInLoaders as ue } from "@babylonjs/loaders/dynamic";
|
|
3
|
+
import { GeospatialCamera as de } from "@babylonjs/core/Cameras/geospatialCamera";
|
|
4
|
+
import { ClusteredLightContainer as fe } from "@babylonjs/core/Lights/Clustered/clusteredLightContainer";
|
|
5
|
+
import { PhysicsViewer as pe } from "@babylonjs/core/Debug/physicsViewer";
|
|
6
|
+
import me from "@babylonjs/havok";
|
|
7
|
+
//#region src/classes/debugConsole.ts
|
|
8
|
+
var he = class {
|
|
9
|
+
_namespaceName;
|
|
10
|
+
_entries = /* @__PURE__ */ new Map();
|
|
11
|
+
_disposed = !1;
|
|
12
|
+
constructor(e = "sage") {
|
|
13
|
+
this._namespaceName = e, this._installNamespace();
|
|
14
|
+
}
|
|
15
|
+
expose(e, t) {
|
|
16
|
+
this._disposed || (this._isDynamicGetter(t) ? (this._entries.set(e, { getter: t.get }), this._defineGetter(e, t.get)) : (this._entries.set(e, { value: t }), this._defineValue(e, t)));
|
|
17
|
+
}
|
|
18
|
+
setNamespace(e) {
|
|
19
|
+
if (!(this._disposed || e === this._namespaceName)) {
|
|
20
|
+
this._removeNamespace(), this._namespaceName = e, this._installNamespace();
|
|
21
|
+
for (let [e, t] of this._entries) t.getter ? this._defineGetter(e, t.getter) : this._defineValue(e, t.value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
get namespaceName() {
|
|
25
|
+
return this._namespaceName;
|
|
26
|
+
}
|
|
27
|
+
dispose() {
|
|
28
|
+
this._disposed ||= (this._removeNamespace(), this._entries.clear(), !0);
|
|
29
|
+
}
|
|
30
|
+
async $teardown() {
|
|
31
|
+
this.dispose();
|
|
32
|
+
}
|
|
33
|
+
_isDynamicGetter(e) {
|
|
34
|
+
return typeof e == "object" && !!e && "get" in e && typeof e.get == "function";
|
|
35
|
+
}
|
|
36
|
+
_getNamespace() {
|
|
37
|
+
return Reflect.get(window, this._namespaceName);
|
|
38
|
+
}
|
|
39
|
+
_installNamespace() {
|
|
40
|
+
typeof window > "u" || Reflect.set(window, this._namespaceName, {});
|
|
41
|
+
}
|
|
42
|
+
_removeNamespace() {
|
|
43
|
+
typeof window > "u" || Reflect.deleteProperty(window, this._namespaceName);
|
|
44
|
+
}
|
|
45
|
+
_defineGetter(e, t) {
|
|
46
|
+
let n = this._getNamespace();
|
|
47
|
+
n && Object.defineProperty(n, e, {
|
|
48
|
+
get: t,
|
|
49
|
+
enumerable: !0,
|
|
50
|
+
configurable: !0
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
_defineValue(e, t) {
|
|
54
|
+
let n = this._getNamespace();
|
|
55
|
+
n && Object.defineProperty(n, e, {
|
|
56
|
+
value: t,
|
|
57
|
+
writable: !0,
|
|
58
|
+
enumerable: !0,
|
|
59
|
+
configurable: !0
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, k = "0.9.4", A = class {
|
|
8
63
|
canvas;
|
|
9
64
|
renderEngine;
|
|
10
65
|
physics;
|
|
@@ -14,14 +69,19 @@ var j = "0.9.2", fe = class {
|
|
|
14
69
|
logger;
|
|
15
70
|
raycast;
|
|
16
71
|
timer;
|
|
72
|
+
debug;
|
|
17
73
|
largeWorldRendering;
|
|
18
74
|
started = !1;
|
|
19
75
|
_log;
|
|
20
76
|
_beforeStartHook = null;
|
|
21
77
|
_onStartHook = null;
|
|
22
78
|
_onTeardownHook = null;
|
|
23
|
-
constructor(e, t, n, r, i, a, o, s, c, l = !1) {
|
|
24
|
-
this.canvas = e, this.renderEngine = t, this.physics = n, this.eventBus = r, this.logger = i, this.raycast = a, this.timer = o, this.engines = s, this.managers = c, this.
|
|
79
|
+
constructor(e, t, n, r, i, a, o, s, c, l = !1, u) {
|
|
80
|
+
this.canvas = e, this.renderEngine = t, this.physics = n, this.eventBus = r, this.logger = i, this.raycast = a, this.timer = o, this.engines = s, this.managers = c, this.debug = u ?? {
|
|
81
|
+
colliders: void 0,
|
|
82
|
+
console: null,
|
|
83
|
+
expose: () => {}
|
|
84
|
+
}, this.largeWorldRendering = l, this._log = i.getLogger("GameEngine");
|
|
25
85
|
}
|
|
26
86
|
onBeforeStart(e) {
|
|
27
87
|
if (this._beforeStartHook !== null) throw Error("A beforeStart hook is already registered. Only one hook is allowed per lifecycle event.");
|
|
@@ -42,17 +102,18 @@ var j = "0.9.2", fe = class {
|
|
|
42
102
|
return this.eventBus.subscribe(`action:${e}`, t);
|
|
43
103
|
}
|
|
44
104
|
async start() {
|
|
45
|
-
this.started ? this._log.warn("Game engine is already started. Skipping start.") : (this._log.info(`Starting SkewedAspect Game Engine (Version: ${
|
|
105
|
+
this.started ? this._log.warn("Game engine is already started. Skipping start.") : (this._log.info(`Starting SkewedAspect Game Engine (Version: ${k})...`), this._beforeStartHook && (this._log.debug("Executing beforeStart hook..."), await this._beforeStartHook(this)), await this.managers.gameManager.start(), this._log.info("Game engine started successfully"), this._onStartHook && (this._log.debug("Executing onStart hook..."), await this._onStartHook(this)), this.started = !0);
|
|
46
106
|
}
|
|
47
107
|
async stop() {
|
|
48
108
|
if (this.started) {
|
|
49
|
-
this._log.info(`Stopping SkewedAspect Game Engine (Version: ${
|
|
109
|
+
this._log.info(`Stopping SkewedAspect Game Engine (Version: ${k})...`);
|
|
50
110
|
let e = null;
|
|
51
111
|
if (this._onTeardownHook) try {
|
|
52
112
|
this._log.debug("Executing onTeardown hook..."), await this._onTeardownHook(this);
|
|
53
113
|
} catch (t) {
|
|
54
114
|
this._log.error(`Error in onTeardown hook: ${t}`), e ||= t;
|
|
55
115
|
}
|
|
116
|
+
this.debug.console && this.debug.console.dispose();
|
|
56
117
|
for (let t of Object.keys(this.managers)) {
|
|
57
118
|
let n = this.managers[t];
|
|
58
119
|
if (n) try {
|
|
@@ -72,7 +133,7 @@ var j = "0.9.2", fe = class {
|
|
|
72
133
|
if (this.started = !1, this._log.info("Game engine stopped successfully"), e) throw e;
|
|
73
134
|
} else this._log.warn("Game engine is not started. Skipping stop.");
|
|
74
135
|
}
|
|
75
|
-
},
|
|
136
|
+
}, j = class {
|
|
76
137
|
timers;
|
|
77
138
|
constructor() {
|
|
78
139
|
this.timers = /* @__PURE__ */ new Map();
|
|
@@ -131,7 +192,7 @@ var j = "0.9.2", fe = class {
|
|
|
131
192
|
console.info(`${a} Timer '${t}' completed in ${i.toFixed(2)}ms`, o, s, c);
|
|
132
193
|
} else console.warn(`[${e}]: Timer '${t}' does not exist`);
|
|
133
194
|
}
|
|
134
|
-
},
|
|
195
|
+
}, M = class {
|
|
135
196
|
trace(e, t, ...n) {}
|
|
136
197
|
debug(e, t, ...n) {}
|
|
137
198
|
info(e, t, ...n) {}
|
|
@@ -139,11 +200,11 @@ var j = "0.9.2", fe = class {
|
|
|
139
200
|
error(e, t, ...n) {}
|
|
140
201
|
time(e, t) {}
|
|
141
202
|
timeEnd(e, t) {}
|
|
142
|
-
},
|
|
203
|
+
}, N = class {
|
|
143
204
|
category;
|
|
144
205
|
backend;
|
|
145
206
|
minLevel;
|
|
146
|
-
constructor(e, t = "none", n = new
|
|
207
|
+
constructor(e, t = "none", n = new M()) {
|
|
147
208
|
this.category = e, this.backend = n, this.minLevel = t;
|
|
148
209
|
}
|
|
149
210
|
updateSettings(e, t) {
|
|
@@ -181,21 +242,21 @@ var j = "0.9.2", fe = class {
|
|
|
181
242
|
default: return !1;
|
|
182
243
|
}
|
|
183
244
|
}
|
|
184
|
-
},
|
|
245
|
+
}, P = class {
|
|
185
246
|
backend;
|
|
186
247
|
level;
|
|
187
248
|
loggers;
|
|
188
|
-
constructor(e = "debug", t = new
|
|
249
|
+
constructor(e = "debug", t = new j()) {
|
|
189
250
|
this.backend = t, this.level = e, this.loggers = /* @__PURE__ */ new Map();
|
|
190
251
|
}
|
|
191
252
|
setBackend(e) {
|
|
192
253
|
this.backend = e, this.loggers.forEach((e) => {
|
|
193
|
-
e instanceof
|
|
254
|
+
e instanceof N && e.updateSettings(this.backend, this.level);
|
|
194
255
|
});
|
|
195
256
|
}
|
|
196
257
|
setLevel(e) {
|
|
197
258
|
this.level = e, this.loggers.forEach((e) => {
|
|
198
|
-
e instanceof
|
|
259
|
+
e instanceof N && e.updateSettings(this.backend, this.level);
|
|
199
260
|
});
|
|
200
261
|
}
|
|
201
262
|
getLevel() {
|
|
@@ -203,14 +264,14 @@ var j = "0.9.2", fe = class {
|
|
|
203
264
|
}
|
|
204
265
|
getLogger(e) {
|
|
205
266
|
let t = this.loggers.get(e);
|
|
206
|
-
return t || (t = new
|
|
267
|
+
return t || (t = new N(e, this.level, this.backend), this.loggers.set(e, t)), t;
|
|
207
268
|
}
|
|
208
|
-
},
|
|
269
|
+
}, F = class {
|
|
209
270
|
directMap = /* @__PURE__ */ new Map();
|
|
210
271
|
patternSubs = /* @__PURE__ */ new Set();
|
|
211
272
|
_log;
|
|
212
273
|
constructor(e) {
|
|
213
|
-
this._log = e?.getLogger("EventBus") || new
|
|
274
|
+
this._log = e?.getLogger("EventBus") || new N("EventBus");
|
|
214
275
|
}
|
|
215
276
|
subscribe(e, t) {
|
|
216
277
|
return this._log.trace(`Subscribe request for: ${e.toString()}`), e instanceof RegExp || typeof e == "string" && e.includes("*") ? this.subscribePattern(e, t) : this.subscribeExact(e, t);
|
|
@@ -255,7 +316,7 @@ var j = "0.9.2", fe = class {
|
|
|
255
316
|
async $teardown() {
|
|
256
317
|
this._log.debug("Tearing down EventBus"), this.directMap.clear(), this.patternSubs.clear();
|
|
257
318
|
}
|
|
258
|
-
},
|
|
319
|
+
}, I = class {
|
|
259
320
|
_engine = null;
|
|
260
321
|
_mainBus = null;
|
|
261
322
|
_buses = /* @__PURE__ */ new Map();
|
|
@@ -299,8 +360,8 @@ var j = "0.9.2", fe = class {
|
|
|
299
360
|
};
|
|
300
361
|
//#endregion
|
|
301
362
|
//#region src/engines/scene.ts
|
|
302
|
-
|
|
303
|
-
var
|
|
363
|
+
ue();
|
|
364
|
+
var L = class {
|
|
304
365
|
_canvas;
|
|
305
366
|
_engine;
|
|
306
367
|
_havok;
|
|
@@ -311,14 +372,14 @@ var P = class {
|
|
|
311
372
|
createScene() {
|
|
312
373
|
return new re(this._engine);
|
|
313
374
|
}
|
|
314
|
-
enablePhysics(e, t = new
|
|
375
|
+
enablePhysics(e, t = new O(0, -9.8, 0), n) {
|
|
315
376
|
this._log.debug(`Enabling physics with gravity (${t.x}, ${t.y}, ${t.z})...`);
|
|
316
377
|
let r = n === void 0 ? void 0 : { floatingOriginWorldRadius: n }, i = new p(!0, this._havok, r);
|
|
317
378
|
e.enablePhysics(t, i);
|
|
318
379
|
}
|
|
319
380
|
createFreeCamera(e, t, n, r) {
|
|
320
381
|
let i = new d(e, t, n);
|
|
321
|
-
return i.setTarget(
|
|
382
|
+
return i.setTarget(O.Zero()), r ??= this._canvas, r && i.attachControl(r, !0), i;
|
|
322
383
|
}
|
|
323
384
|
createHemisphericLight(e, t, n, r = .7) {
|
|
324
385
|
let i = new m(e, t, n);
|
|
@@ -329,15 +390,15 @@ var P = class {
|
|
|
329
390
|
return i.intensity = r, i;
|
|
330
391
|
}
|
|
331
392
|
createPointLight(e, t, n, r = 1) {
|
|
332
|
-
let i = new
|
|
393
|
+
let i = new ee(e, t, n);
|
|
333
394
|
return i.intensity = r, i;
|
|
334
395
|
}
|
|
335
396
|
createSpotLight(e, t, n, r, i, a, o = 1) {
|
|
336
|
-
let s = new
|
|
397
|
+
let s = new oe(e, t, n, r, i, a);
|
|
337
398
|
return s.intensity = o, s;
|
|
338
399
|
}
|
|
339
400
|
createRectAreaLight(e, t, n, r, i, a = 1) {
|
|
340
|
-
let o = new
|
|
401
|
+
let o = new te(e, t, n, r, i);
|
|
341
402
|
return o.intensity = a, o;
|
|
342
403
|
}
|
|
343
404
|
createSphere(e, t = {}, n) {
|
|
@@ -370,7 +431,7 @@ var P = class {
|
|
|
370
431
|
}, n);
|
|
371
432
|
}
|
|
372
433
|
addPhysics(e, t, n = {}, r) {
|
|
373
|
-
return new
|
|
434
|
+
return new C(e, t, {
|
|
374
435
|
mass: 1,
|
|
375
436
|
restitution: .75,
|
|
376
437
|
friction: .5,
|
|
@@ -398,14 +459,14 @@ var P = class {
|
|
|
398
459
|
async $teardown() {
|
|
399
460
|
this._log.info("Tearing down SceneEngine"), this._log.info("SceneEngine torn down successfully");
|
|
400
461
|
}
|
|
401
|
-
},
|
|
462
|
+
}, R = class {
|
|
402
463
|
_eventBus;
|
|
403
464
|
_sceneEngine;
|
|
404
465
|
_log;
|
|
405
466
|
_containers = /* @__PURE__ */ new Map();
|
|
406
467
|
_sourceMeshes = /* @__PURE__ */ new Map();
|
|
407
468
|
constructor(e, t, n) {
|
|
408
|
-
this._eventBus = e, this._sceneEngine = t, this._log = n?.getLogger("AssetManager") ?? new
|
|
469
|
+
this._eventBus = e, this._sceneEngine = t, this._log = n?.getLogger("AssetManager") ?? new N("AssetManager");
|
|
409
470
|
}
|
|
410
471
|
_parsePath(e) {
|
|
411
472
|
let t = e.indexOf("#");
|
|
@@ -491,22 +552,22 @@ var P = class {
|
|
|
491
552
|
async $teardown() {
|
|
492
553
|
this.disposeAll();
|
|
493
554
|
}
|
|
494
|
-
},
|
|
555
|
+
}, z = [
|
|
495
556
|
"trigger",
|
|
496
557
|
"toggle",
|
|
497
558
|
"value"
|
|
498
|
-
],
|
|
559
|
+
], ge = [
|
|
499
560
|
"keyboard",
|
|
500
561
|
"mouse",
|
|
501
562
|
"gamepad"
|
|
502
563
|
];
|
|
503
|
-
function
|
|
564
|
+
function _e(e) {
|
|
504
565
|
return e.type === "keyboard";
|
|
505
566
|
}
|
|
506
|
-
function
|
|
567
|
+
function B(e) {
|
|
507
568
|
return e.type === "mouse";
|
|
508
569
|
}
|
|
509
|
-
function
|
|
570
|
+
function V(e) {
|
|
510
571
|
return e.type === "gamepad";
|
|
511
572
|
}
|
|
512
573
|
//#endregion
|
|
@@ -831,7 +892,7 @@ var ve = class {
|
|
|
831
892
|
this._eventBus = e, this._inputUnsubscribe = this._eventBus.subscribe("input:changed", (e) => {
|
|
832
893
|
let t = e.payload;
|
|
833
894
|
t && this.$handleInput(t.device, t.state);
|
|
834
|
-
}), this._log = t?.getLogger("BindingManager") || new
|
|
895
|
+
}), this._log = t?.getLogger("BindingManager") || new N("BindingManager"), this._log.debug("BindingManager initialized");
|
|
835
896
|
}
|
|
836
897
|
_isBindingContextActive(e) {
|
|
837
898
|
return e.context ? this._activeContexts.has(e.context) : !0;
|
|
@@ -849,7 +910,7 @@ var ve = class {
|
|
|
849
910
|
return t;
|
|
850
911
|
}
|
|
851
912
|
_shouldUpdateActiveDevice(e) {
|
|
852
|
-
return
|
|
913
|
+
return B(e) ? Object.values(e.buttons).some((e) => e.pressed) || e.wheel !== void 0 : V(e) ? Object.values(e.buttons).some((e) => e.pressed) || Object.values(e.axes).some((e) => Math.abs(e) > we) : !0;
|
|
853
914
|
}
|
|
854
915
|
_createBindingFromDefinition(e) {
|
|
855
916
|
let t = this._actions.get(e.action);
|
|
@@ -893,7 +954,7 @@ var ve = class {
|
|
|
893
954
|
let { options: r } = n;
|
|
894
955
|
if (!r.deviceTypes.includes(e.type)) return;
|
|
895
956
|
let i = null;
|
|
896
|
-
if (
|
|
957
|
+
if (_e(t)) {
|
|
897
958
|
if (t.event?.repeat === !0) return;
|
|
898
959
|
for (let n of Object.keys(t.delta)) if (t.delta[n] === !0) {
|
|
899
960
|
i = {
|
|
@@ -904,7 +965,7 @@ var ve = class {
|
|
|
904
965
|
};
|
|
905
966
|
break;
|
|
906
967
|
}
|
|
907
|
-
} else if (
|
|
968
|
+
} else if (B(t)) {
|
|
908
969
|
for (let n of Object.keys(t.buttons)) if (t.buttons[n].pressed) {
|
|
909
970
|
i = {
|
|
910
971
|
type: "mouse",
|
|
@@ -914,7 +975,7 @@ var ve = class {
|
|
|
914
975
|
};
|
|
915
976
|
break;
|
|
916
977
|
}
|
|
917
|
-
} else if (
|
|
978
|
+
} else if (V(t)) {
|
|
918
979
|
for (let n of Object.keys(t.buttons)) if (t.buttons[n].pressed) {
|
|
919
980
|
i = {
|
|
920
981
|
type: "gamepad",
|
|
@@ -1040,7 +1101,7 @@ var ve = class {
|
|
|
1040
1101
|
return this._contexts.get(e) || null;
|
|
1041
1102
|
}
|
|
1042
1103
|
$registerBinding(e) {
|
|
1043
|
-
if (!
|
|
1104
|
+
if (!z.includes(e.type)) throw Error(`Invalid binding type: ${e.type}`);
|
|
1044
1105
|
e.context && !this._contexts.has(e.context) && this.registerContext(e.context), this._bindings.has(e.deviceID) || this._bindings.set(e.deviceID, []), this._bindings.get(e.deviceID)?.push(e), this._log.debug(`Registered ${e.type} binding for "${e.action.name}" in context "${e.context || null}"`);
|
|
1045
1106
|
}
|
|
1046
1107
|
registerBinding(e) {
|
|
@@ -1110,15 +1171,15 @@ var ve = class {
|
|
|
1110
1171
|
};
|
|
1111
1172
|
//#endregion
|
|
1112
1173
|
//#region src/utils/capabilities.ts
|
|
1113
|
-
function
|
|
1174
|
+
function H() {
|
|
1114
1175
|
return typeof window < "u" && window.document !== void 0;
|
|
1115
1176
|
}
|
|
1116
|
-
function
|
|
1117
|
-
return
|
|
1177
|
+
function De() {
|
|
1178
|
+
return H() && !!window.navigator.gpu;
|
|
1118
1179
|
}
|
|
1119
1180
|
//#endregion
|
|
1120
1181
|
//#region node_modules/hexoid/dist/index.mjs
|
|
1121
|
-
for (var
|
|
1182
|
+
for (var Oe = class {
|
|
1122
1183
|
_engine;
|
|
1123
1184
|
_eventBus;
|
|
1124
1185
|
_entityManager;
|
|
@@ -1132,7 +1193,7 @@ for (var De = class {
|
|
|
1132
1193
|
_paused = !1;
|
|
1133
1194
|
started = !1;
|
|
1134
1195
|
constructor(e, t, n, r, i, a) {
|
|
1135
|
-
this._engine = e, this._eventBus = t, this._entityManager = n, this._inputManager = r, this._levelManager = i, this._log = a?.getLogger("GameManager") || new
|
|
1196
|
+
this._engine = e, this._eventBus = t, this._entityManager = n, this._inputManager = r, this._levelManager = i, this._log = a?.getLogger("GameManager") || new N("GameManager"), this._boundRenderLoop = this._renderLoop.bind(this), this._boundResizeHandler = this._resizeHandler.bind(this), H() && window.addEventListener("resize", this._boundResizeHandler);
|
|
1136
1197
|
}
|
|
1137
1198
|
get currentScene() {
|
|
1138
1199
|
return this._levelManager.currentLevel?.scene ?? null;
|
|
@@ -1192,23 +1253,23 @@ for (var De = class {
|
|
|
1192
1253
|
});
|
|
1193
1254
|
}
|
|
1194
1255
|
async $teardown() {
|
|
1195
|
-
this._log.info("Tearing down GameManager"), this.started && await this.stop(),
|
|
1256
|
+
this._log.info("Tearing down GameManager"), this.started && await this.stop(), H() && window.removeEventListener("resize", this._boundResizeHandler), this._frameCallbacks = [], this._log.info("GameManager torn down successfully");
|
|
1196
1257
|
}
|
|
1197
|
-
},
|
|
1198
|
-
function
|
|
1258
|
+
}, U = 256, W = []; U--;) W[U] = (U + 256).toString(16).substring(1);
|
|
1259
|
+
function ke(e) {
|
|
1199
1260
|
e ||= 16;
|
|
1200
1261
|
var t = "", n = 0;
|
|
1201
1262
|
return function() {
|
|
1202
1263
|
if (!t || n === 256) {
|
|
1203
|
-
for (t = "", n = (1 + e) / 2 | 0; n--;) t +=
|
|
1264
|
+
for (t = "", n = (1 + e) / 2 | 0; n--;) t += W[256 * Math.random() | 0];
|
|
1204
1265
|
t = t.substring(n = 0, e - 2);
|
|
1205
1266
|
}
|
|
1206
|
-
return t +
|
|
1267
|
+
return t + W[n++];
|
|
1207
1268
|
};
|
|
1208
1269
|
}
|
|
1209
1270
|
//#endregion
|
|
1210
1271
|
//#region src/utils/id.ts
|
|
1211
|
-
var
|
|
1272
|
+
var Ae = ke(16), G = class {
|
|
1212
1273
|
entity = null;
|
|
1213
1274
|
$emit(e) {
|
|
1214
1275
|
if (!this.entity) throw Error("Entity is not set for this behavior.");
|
|
@@ -1229,7 +1290,7 @@ var W = Oe(16), G = class {
|
|
|
1229
1290
|
$setEntity(e) {
|
|
1230
1291
|
this.entity = e;
|
|
1231
1292
|
}
|
|
1232
|
-
},
|
|
1293
|
+
}, je = class {
|
|
1233
1294
|
id;
|
|
1234
1295
|
type;
|
|
1235
1296
|
name;
|
|
@@ -1244,7 +1305,7 @@ var W = Oe(16), G = class {
|
|
|
1244
1305
|
_tags = /* @__PURE__ */ new Set();
|
|
1245
1306
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1246
1307
|
constructor(e, t, n, r, i) {
|
|
1247
|
-
this.id =
|
|
1308
|
+
this.id = Ae(), this.type = e, this.name = i, this.state = n, this.eventBus = t;
|
|
1248
1309
|
for (let e of r) this.attachBehavior(new e());
|
|
1249
1310
|
}
|
|
1250
1311
|
get tags() {
|
|
@@ -1287,6 +1348,51 @@ var W = Oe(16), G = class {
|
|
|
1287
1348
|
let t = this._gameEngine?.managers?.levelManager?.currentLevel?.outlines;
|
|
1288
1349
|
t && (e ? t.unhighlightEntity(e, this) : t.unhighlightEntityAll(this));
|
|
1289
1350
|
}
|
|
1351
|
+
showCollider(e, t) {
|
|
1352
|
+
if (!this.node || !this._gameEngine) return;
|
|
1353
|
+
let n = this._gameEngine.debug?.colliders;
|
|
1354
|
+
if (!n) return;
|
|
1355
|
+
let r = this._getPhysicsNodes();
|
|
1356
|
+
if (e === void 0 || e === !0) {
|
|
1357
|
+
for (let e of r) n.showColliderForNode(e, void 0);
|
|
1358
|
+
return;
|
|
1359
|
+
}
|
|
1360
|
+
if (typeof e == "string") {
|
|
1361
|
+
if (e.startsWith("#")) {
|
|
1362
|
+
for (let t of r) n.showColliderForNode(t, e);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
let i = r.find((t) => t.name === e);
|
|
1366
|
+
i && n.showColliderForNode(i, t);
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
if (typeof e == "object") {
|
|
1370
|
+
let t = e;
|
|
1371
|
+
for (let e of r) {
|
|
1372
|
+
let r = t[e.name];
|
|
1373
|
+
r && n.showColliderForNode(e, r);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
hideCollider(e) {
|
|
1378
|
+
if (!this.node || !this._gameEngine) return;
|
|
1379
|
+
let t = this._gameEngine.debug?.colliders;
|
|
1380
|
+
if (!t) return;
|
|
1381
|
+
let n = this._getPhysicsNodes();
|
|
1382
|
+
if (e === void 0) {
|
|
1383
|
+
for (let e of n) t.hideColliderForNode(e);
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
let r = n.find((t) => t.name === e);
|
|
1387
|
+
r && t.hideColliderForNode(r);
|
|
1388
|
+
}
|
|
1389
|
+
_getPhysicsNodes() {
|
|
1390
|
+
if (!this.node) return [];
|
|
1391
|
+
let e = [];
|
|
1392
|
+
this.node.physicsBody && e.push(this.node);
|
|
1393
|
+
for (let t of this.node.getChildTransformNodes(!1)) t.physicsBody && e.push(t);
|
|
1394
|
+
return e;
|
|
1395
|
+
}
|
|
1290
1396
|
$addChild(e) {
|
|
1291
1397
|
this.children.push(e), e.parent = this, this.node && e.node && (e.node.parent = this.node);
|
|
1292
1398
|
}
|
|
@@ -1413,7 +1519,7 @@ var W = Oe(16), G = class {
|
|
|
1413
1519
|
}
|
|
1414
1520
|
return this.behaviors.splice(t, 1), n.$setEntity(null), !0;
|
|
1415
1521
|
}
|
|
1416
|
-
},
|
|
1522
|
+
}, Me = class {
|
|
1417
1523
|
eventBus;
|
|
1418
1524
|
entities = /* @__PURE__ */ new Map();
|
|
1419
1525
|
entityDefinitions = /* @__PURE__ */ new Map();
|
|
@@ -1426,7 +1532,7 @@ var W = Oe(16), G = class {
|
|
|
1426
1532
|
_entitiesByNode = /* @__PURE__ */ new Map();
|
|
1427
1533
|
_pools = /* @__PURE__ */ new Map();
|
|
1428
1534
|
constructor(e, t, n) {
|
|
1429
|
-
this.eventBus = e, this.bindingManager = n, this._log = t?.getLogger("EntityManager") || new
|
|
1535
|
+
this.eventBus = e, this.bindingManager = n, this._log = t?.getLogger("EntityManager") || new N("EntityManager"), this._log.info("EntityManager initialized");
|
|
1430
1536
|
}
|
|
1431
1537
|
$setGameEngine(e) {
|
|
1432
1538
|
this._gameEngine = e;
|
|
@@ -1537,7 +1643,7 @@ var W = Oe(16), G = class {
|
|
|
1537
1643
|
let t = await n.onBeforeCreate(r);
|
|
1538
1644
|
t !== void 0 && (r = t);
|
|
1539
1645
|
}
|
|
1540
|
-
let i = t.name ?? n.name, a = new
|
|
1646
|
+
let i = t.name ?? n.name, a = new je(n.type, this.eventBus, r, n.behaviors, i);
|
|
1541
1647
|
if (a.$setEntityManager(this), t.node && a.$attachToNode(t.node, this._engine), n.tags) for (let e of n.tags) a.$addTag(e);
|
|
1542
1648
|
if (t.tags) for (let e of t.tags) a.$addTag(e);
|
|
1543
1649
|
if (this.entities.set(a.id, a), this._indexEntity(a), this._log.debug(`Entity created with ID: ${a.id}${i ? ` (name: ${i})` : ""}`), n.onCreate) {
|
|
@@ -1707,18 +1813,18 @@ var W = Oe(16), G = class {
|
|
|
1707
1813
|
}
|
|
1708
1814
|
this.entityDefinitions.clear(), this._entitiesByName.clear(), this._entitiesByType.clear(), this._entitiesByTag.clear(), this._entitiesByNode.clear(), this._log.info("EntityManager torn down successfully");
|
|
1709
1815
|
}
|
|
1710
|
-
},
|
|
1816
|
+
}, Ne = {
|
|
1711
1817
|
hable: h.TONEMAPPING_STANDARD,
|
|
1712
1818
|
reinhard: h.TONEMAPPING_STANDARD,
|
|
1713
1819
|
hejidawson: h.TONEMAPPING_STANDARD,
|
|
1714
1820
|
photographic: h.TONEMAPPING_STANDARD,
|
|
1715
1821
|
aces: h.TONEMAPPING_ACES
|
|
1716
1822
|
};
|
|
1717
|
-
function
|
|
1823
|
+
function Pe(e, t) {
|
|
1718
1824
|
if (!e.activeCamera) return;
|
|
1719
1825
|
t.volumetric && console.warn("[SAGE] Volumetric lighting requires renderer: \"frameGraph\". Ignored in pipeline mode.");
|
|
1720
1826
|
let n = new s("sage-default", !0, e, e.cameras);
|
|
1721
|
-
if (t.bloom && (n.bloomEnabled = !0, t.bloom.weight !== void 0 && (n.bloomWeight = t.bloom.weight), t.bloom.threshold !== void 0 && (n.bloomThreshold = t.bloom.threshold), t.bloom.scale !== void 0 && (n.bloomScale = t.bloom.scale), t.bloom.kernel !== void 0 && (n.bloomKernel = t.bloom.kernel)), t.tonemap && (n.imageProcessingEnabled = !0, n.imageProcessing.toneMappingEnabled = !0, t.tonemap.operator && (n.imageProcessing.toneMappingType =
|
|
1827
|
+
if (t.bloom && (n.bloomEnabled = !0, t.bloom.weight !== void 0 && (n.bloomWeight = t.bloom.weight), t.bloom.threshold !== void 0 && (n.bloomThreshold = t.bloom.threshold), t.bloom.scale !== void 0 && (n.bloomScale = t.bloom.scale), t.bloom.kernel !== void 0 && (n.bloomKernel = t.bloom.kernel)), t.tonemap && (n.imageProcessingEnabled = !0, n.imageProcessing.toneMappingEnabled = !0, t.tonemap.operator && (n.imageProcessing.toneMappingType = Ne[t.tonemap.operator] ?? h.TONEMAPPING_STANDARD)), t.grain && (n.grainEnabled = !0, t.grain.intensity !== void 0 && (n.grain.intensity = t.grain.intensity), t.grain.animated !== void 0 && (n.grain.animated = t.grain.animated)), t.vignette && (n.imageProcessingEnabled = !0, n.imageProcessing.vignetteEnabled = !0, t.vignette.weight !== void 0 && (n.imageProcessing.vignetteWeight = t.vignette.weight), t.vignette.stretch !== void 0 && (n.imageProcessing.vignetteStretch = t.vignette.stretch), t.vignette.color && (n.imageProcessing.vignetteColor = new i(t.vignette.color.r, t.vignette.color.g, t.vignette.color.b, 1))), t.sharpen && (n.sharpenEnabled = !0, t.sharpen.edge !== void 0 && (n.sharpen.edgeAmount = t.sharpen.edge), t.sharpen.color !== void 0 && (n.sharpen.colorAmount = t.sharpen.color)), t.chromaticAberration && (n.chromaticAberrationEnabled = !0, t.chromaticAberration.amount !== void 0 && (n.chromaticAberration.aberrationAmount = t.chromaticAberration.amount)), t.ssao) {
|
|
1722
1828
|
let n = new ne("sage-ssao", e, {
|
|
1723
1829
|
ssaoRatio: .5,
|
|
1724
1830
|
blurRatio: 1
|
|
@@ -1728,25 +1834,25 @@ function je(e, t) {
|
|
|
1728
1834
|
}
|
|
1729
1835
|
//#endregion
|
|
1730
1836
|
//#region src/handlers/postProcessing.ts
|
|
1731
|
-
async function
|
|
1837
|
+
async function Fe(e, t) {
|
|
1732
1838
|
if (t.renderer === "frameGraph") {
|
|
1733
1839
|
let { applyFrameGraphPostProcessing: n } = await import("./postProcessingFrameGraph-CaMgQzR-.js");
|
|
1734
1840
|
await n(e, t);
|
|
1735
|
-
} else
|
|
1841
|
+
} else Pe(e, t);
|
|
1736
1842
|
}
|
|
1737
1843
|
//#endregion
|
|
1738
1844
|
//#region src/utils/vectors.ts
|
|
1739
|
-
function
|
|
1845
|
+
function K(e) {
|
|
1740
1846
|
return {
|
|
1741
1847
|
x: e.x,
|
|
1742
1848
|
y: e.y,
|
|
1743
1849
|
z: e.z
|
|
1744
1850
|
};
|
|
1745
1851
|
}
|
|
1746
|
-
function
|
|
1747
|
-
return new
|
|
1852
|
+
function q(e) {
|
|
1853
|
+
return new O(e.x, e.y, e.z);
|
|
1748
1854
|
}
|
|
1749
|
-
function
|
|
1855
|
+
function Ie(e) {
|
|
1750
1856
|
return {
|
|
1751
1857
|
x: e.x,
|
|
1752
1858
|
y: e.y,
|
|
@@ -1754,21 +1860,18 @@ function Ne(e) {
|
|
|
1754
1860
|
w: e.w
|
|
1755
1861
|
};
|
|
1756
1862
|
}
|
|
1757
|
-
function
|
|
1758
|
-
return new
|
|
1863
|
+
function Le(e) {
|
|
1864
|
+
return new T(e.x, e.y, e.z, e.w);
|
|
1759
1865
|
}
|
|
1760
|
-
function
|
|
1761
|
-
return v.Compose(e.scaling, e.rotationQuaternion ?? w.FromEulerVector(e.rotation), e.position);
|
|
1762
|
-
}
|
|
1763
|
-
function Ie(e) {
|
|
1866
|
+
function Re(e) {
|
|
1764
1867
|
e.computeWorldMatrix(!0);
|
|
1765
|
-
let t =
|
|
1868
|
+
let t = e.getWorldMatrix().clone(), n = e.parent;
|
|
1766
1869
|
for (; n;) {
|
|
1767
1870
|
n.computeWorldMatrix(!0);
|
|
1768
|
-
let e =
|
|
1769
|
-
e.determinant()
|
|
1871
|
+
let e = n.getWorldMatrix(), r = n.parent, i;
|
|
1872
|
+
r ? (r.computeWorldMatrix(!0), i = e.multiply(v.Invert(r.getWorldMatrix()))) : i = e, i.determinant() < 0 && (t = v.Invert(i).multiply(t)), n = r;
|
|
1770
1873
|
}
|
|
1771
|
-
let r = new
|
|
1874
|
+
let r = new O(), i = new T(), a = new O();
|
|
1772
1875
|
return t.decompose(a, i, r), {
|
|
1773
1876
|
position: r,
|
|
1774
1877
|
rotation: i,
|
|
@@ -1777,7 +1880,7 @@ function Ie(e) {
|
|
|
1777
1880
|
}
|
|
1778
1881
|
//#endregion
|
|
1779
1882
|
//#region src/classes/level.ts
|
|
1780
|
-
var
|
|
1883
|
+
var ze = class {
|
|
1781
1884
|
name;
|
|
1782
1885
|
_log;
|
|
1783
1886
|
_context;
|
|
@@ -1785,7 +1888,7 @@ var Le = class {
|
|
|
1785
1888
|
clusteredLights = null;
|
|
1786
1889
|
outlines = null;
|
|
1787
1890
|
constructor(e, t) {
|
|
1788
|
-
this.name = e.name, this._context = t, this._log = t.logger?.getLogger(`Level:${e.name}`) ?? new
|
|
1891
|
+
this.name = e.name, this._context = t, this._log = t.logger?.getLogger(`Level:${e.name}`) ?? new N(`Level:${e.name}`, "info");
|
|
1789
1892
|
}
|
|
1790
1893
|
get scene() {
|
|
1791
1894
|
return this._scene;
|
|
@@ -1840,7 +1943,7 @@ var Le = class {
|
|
|
1840
1943
|
this.outlines &&= (this.outlines.dispose(), null), this.clusteredLights &&= (this.clusteredLights.dispose(), null), this._scene.dispose(), this._scene = null;
|
|
1841
1944
|
}
|
|
1842
1945
|
}
|
|
1843
|
-
},
|
|
1946
|
+
}, Be = class {
|
|
1844
1947
|
_scene;
|
|
1845
1948
|
_layers = /* @__PURE__ */ new Map();
|
|
1846
1949
|
constructor(e, t) {
|
|
@@ -1884,7 +1987,7 @@ var Le = class {
|
|
|
1884
1987
|
n.length > 0 && e.layer.addSelection(n);
|
|
1885
1988
|
}
|
|
1886
1989
|
}
|
|
1887
|
-
},
|
|
1990
|
+
}, Ve = class extends ze {
|
|
1888
1991
|
_config;
|
|
1889
1992
|
_spawnPoints = [];
|
|
1890
1993
|
_entityNodes = [];
|
|
@@ -1906,9 +2009,9 @@ var Le = class {
|
|
|
1906
2009
|
let n = e.createScene();
|
|
1907
2010
|
if (this._scene = n, 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) {
|
|
1908
2011
|
let e = this._config.postProcessing.renderer ?? "pipeline";
|
|
1909
|
-
this._log.info(`Applying post-processing with ${e} renderer`), await
|
|
2012
|
+
this._log.info(`Applying post-processing with ${e} renderer`), await Fe(n, this._config.postProcessing);
|
|
1910
2013
|
}
|
|
1911
|
-
return this.outlines = new
|
|
2014
|
+
return this.outlines = new Be(n, this._config.outlines), this.$emitProgress(50, "Processing scene properties..."), await this._processNodeProperties(n), this.$emitProgress(70, "Spawning entities..."), await this._processSpawnPoints(), this.$emitProgress(85, "Configuring entities..."), await this._processEntityNodes(), this._config.sounds && (this.$emitProgress(95, "Loading sounds..."), await this._processLevelSounds()), n;
|
|
1912
2015
|
}
|
|
1913
2016
|
async _loadSceneFile(e) {
|
|
1914
2017
|
let t = this._getScenePath();
|
|
@@ -1942,8 +2045,8 @@ var Le = class {
|
|
|
1942
2045
|
let n = t.skyboxSize ?? 1e3, r = b.CreateSphere("skybox", {
|
|
1943
2046
|
diameter: n,
|
|
1944
2047
|
segments: 32
|
|
1945
|
-
}, e), i = new
|
|
1946
|
-
i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new
|
|
2048
|
+
}, e), i = new E("skybox-mat", e);
|
|
2049
|
+
i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new se(t.skybox, e), r.material = i, r.infiniteDistance = !0;
|
|
1947
2050
|
}
|
|
1948
2051
|
this._log.debug(`Skybox set from: ${t.skybox}`);
|
|
1949
2052
|
}
|
|
@@ -1979,20 +2082,20 @@ var Le = class {
|
|
|
1979
2082
|
}
|
|
1980
2083
|
}
|
|
1981
2084
|
_createCamera(e, t, r) {
|
|
1982
|
-
let i = t.position ?
|
|
2085
|
+
let i = t.position ? q(t.position) : O.Zero(), a;
|
|
1983
2086
|
switch (t.type) {
|
|
1984
2087
|
case "arcRotate": {
|
|
1985
|
-
let i = t.target ?
|
|
2088
|
+
let i = t.target ? q(t.target) : O.Zero();
|
|
1986
2089
|
a = new n(e, t.alpha ?? Math.PI / 2, t.beta ?? Math.PI / 3, t.radius ?? 10, i, r);
|
|
1987
2090
|
break;
|
|
1988
2091
|
}
|
|
1989
2092
|
case "universal":
|
|
1990
|
-
a = new
|
|
2093
|
+
a = new ce(e, i, r);
|
|
1991
2094
|
break;
|
|
1992
2095
|
case "geospatial": {
|
|
1993
|
-
if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e,
|
|
1994
|
-
let n = new
|
|
1995
|
-
t.center && (n.center =
|
|
2096
|
+
if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e, O.Zero(), r);
|
|
2097
|
+
let n = new de(e, r, { planetRadius: t.planetRadius });
|
|
2098
|
+
t.center && (n.center = q(t.center)), t.yaw !== void 0 && (n.yaw = t.yaw), t.pitch !== void 0 && (n.pitch = t.pitch), t.radius !== void 0 && (n.radius = t.radius), t.checkCollisions !== void 0 && (n.checkCollisions = t.checkCollisions), t.radiusMin !== void 0 && (n.limits.radiusMin = t.radiusMin), t.radiusMax !== void 0 && (n.limits.radiusMax = t.radiusMax), t.pitchMin !== void 0 && (n.limits.pitchMin = t.pitchMin), t.pitchMax !== void 0 && (n.limits.pitchMax = t.pitchMax), t.yawMin !== void 0 && (n.limits.yawMin = t.yawMin), t.yawMax !== void 0 && (n.limits.yawMax = t.yawMax), a = n;
|
|
1996
2099
|
break;
|
|
1997
2100
|
}
|
|
1998
2101
|
default:
|
|
@@ -2002,7 +2105,7 @@ var Le = class {
|
|
|
2002
2105
|
return this._applyCameraConfig(a, t), a;
|
|
2003
2106
|
}
|
|
2004
2107
|
_applyCameraConfig(e, t) {
|
|
2005
|
-
t.fov !== void 0 && (e.fov = t.fov), t.position && (e.position =
|
|
2108
|
+
t.fov !== void 0 && (e.fov = t.fov), t.position && (e.position = q(t.position)), t.minZ !== void 0 && (e.minZ = t.minZ), t.maxZ !== void 0 && (e.maxZ = t.maxZ), e instanceof d && (t.speed !== void 0 && (e.speed = t.speed), t.rotation && (e.rotation = q(t.rotation))), e instanceof n && (t.target && e.setTarget(q(t.target)), t.lowerRadiusLimit !== void 0 && (e.lowerRadiusLimit = t.lowerRadiusLimit), t.upperRadiusLimit !== void 0 && (e.upperRadiusLimit = t.upperRadiusLimit), t.lowerBetaLimit !== void 0 && (e.lowerBetaLimit = t.lowerBetaLimit), t.upperBetaLimit !== void 0 && (e.upperBetaLimit = t.upperBetaLimit), t.wheelPrecision !== void 0 && (e.wheelPrecision = t.wheelPrecision)), e instanceof de && (t.yaw !== void 0 && (e.yaw = t.yaw), t.pitch !== void 0 && (e.pitch = t.pitch), t.radius !== void 0 && (e.radius = t.radius), t.center && (e.center = q(t.center)), t.checkCollisions !== void 0 && (e.checkCollisions = t.checkCollisions), t.radiusMin !== void 0 && (e.limits.radiusMin = t.radiusMin), t.radiusMax !== void 0 && (e.limits.radiusMax = t.radiusMax), t.pitchMin !== void 0 && (e.limits.pitchMin = t.pitchMin), t.pitchMax !== void 0 && (e.limits.pitchMax = t.pitchMax));
|
|
2006
2109
|
}
|
|
2007
2110
|
_processLights(e) {
|
|
2008
2111
|
let t = this._config.lights;
|
|
@@ -2012,7 +2115,7 @@ var Le = class {
|
|
|
2012
2115
|
}
|
|
2013
2116
|
}
|
|
2014
2117
|
_createLight(e, t, n) {
|
|
2015
|
-
let r = t.direction ?
|
|
2118
|
+
let r = t.direction ? q(t.direction) : new O(0, -1, 0), i = t.position ? q(t.position) : O.Zero();
|
|
2016
2119
|
switch (t.type) {
|
|
2017
2120
|
case "hemispheric": {
|
|
2018
2121
|
let i = new m(e, r, n);
|
|
@@ -2025,20 +2128,20 @@ var Le = class {
|
|
|
2025
2128
|
break;
|
|
2026
2129
|
}
|
|
2027
2130
|
case "point": {
|
|
2028
|
-
let r = new
|
|
2131
|
+
let r = new ee(e, i, n);
|
|
2029
2132
|
this._applyLightConfig(r, t);
|
|
2030
2133
|
break;
|
|
2031
2134
|
}
|
|
2032
2135
|
case "spot": {
|
|
2033
|
-
let a = new
|
|
2136
|
+
let a = new oe(e, i, r, t.angle ?? Math.PI / 3, t.exponent ?? 2, n);
|
|
2034
2137
|
this._applyLightConfig(a, t);
|
|
2035
2138
|
break;
|
|
2036
2139
|
}
|
|
2037
2140
|
case "rectarea": {
|
|
2038
|
-
let a = new
|
|
2141
|
+
let a = new te(e, i, t.width ?? 1, t.height ?? 1, n);
|
|
2039
2142
|
if (this._applyLightConfig(a, t), t.direction) {
|
|
2040
|
-
let t = new
|
|
2041
|
-
t.position = a.position.clone(), a.position =
|
|
2143
|
+
let t = new D(`${e}_pivot`, n);
|
|
2144
|
+
t.position = a.position.clone(), a.position = O.Zero(), a.parent = t, t.lookAt(t.position.subtract(r));
|
|
2042
2145
|
}
|
|
2043
2146
|
break;
|
|
2044
2147
|
}
|
|
@@ -2050,22 +2153,22 @@ var Le = class {
|
|
|
2050
2153
|
_setupClustering(e) {
|
|
2051
2154
|
let t = this._config.clustering;
|
|
2052
2155
|
if (!t?.enabled) return;
|
|
2053
|
-
let n = e.lights.filter((e) =>
|
|
2156
|
+
let n = e.lights.filter((e) => fe.IsLightSupported(e));
|
|
2054
2157
|
if (n.length === 0) {
|
|
2055
2158
|
this._log.debug("Clustering enabled but no eligible lights found");
|
|
2056
2159
|
return;
|
|
2057
2160
|
}
|
|
2058
2161
|
for (let t of n) e.removeLight(t);
|
|
2059
|
-
let r = new
|
|
2162
|
+
let r = new fe("sage-clustered", n, e);
|
|
2060
2163
|
t.horizontalTiles !== void 0 && (r.horizontalTiles = t.horizontalTiles), t.verticalTiles !== void 0 && (r.verticalTiles = t.verticalTiles), t.depthSlices !== void 0 && (r.depthSlices = t.depthSlices), t.maxRange !== void 0 && (r.maxRange = t.maxRange), this.clusteredLights = r, this._log.debug(`Clustered lighting enabled: ${n.length} lights, ${r.horizontalTiles}x${r.verticalTiles} tiles, ${r.depthSlices} depth slices`);
|
|
2061
|
-
for (let t of e.materials) t instanceof
|
|
2164
|
+
for (let t of e.materials) t instanceof S && (t.useGLTFLightFalloff = !0);
|
|
2062
2165
|
}
|
|
2063
2166
|
_toColor3(e) {
|
|
2064
2167
|
return new r(e.r, e.g, e.b);
|
|
2065
2168
|
}
|
|
2066
2169
|
async _enablePhysics(e) {
|
|
2067
|
-
let t = this._config.physics, n = new
|
|
2068
|
-
typeof t == "object" && t.gravity && (n = new
|
|
2170
|
+
let t = this._config.physics, n = new O(0, -9.81, 0);
|
|
2171
|
+
typeof t == "object" && t.gravity && (n = new O(t.gravity.x, t.gravity.y, t.gravity.z));
|
|
2069
2172
|
let r = this.gameEngine.largeWorldRendering ? 1e5 : void 0;
|
|
2070
2173
|
this._log.debug(`Enabling physics with gravity: ${n.toString()}`), await this.gameEngine.engines.sceneEngine.enablePhysics(e, n, r);
|
|
2071
2174
|
}
|
|
@@ -2087,7 +2190,7 @@ var Le = class {
|
|
|
2087
2190
|
}
|
|
2088
2191
|
async _processNodeMetadata(e) {
|
|
2089
2192
|
if ("spawn" in e.metadata) {
|
|
2090
|
-
let { position: t, rotation: n, scaling: r } =
|
|
2193
|
+
let { position: t, rotation: n, scaling: r } = Re(e);
|
|
2091
2194
|
this._spawnPoints.push({
|
|
2092
2195
|
name: e.metadata.spawn,
|
|
2093
2196
|
position: t,
|
|
@@ -2117,17 +2220,21 @@ var Le = class {
|
|
|
2117
2220
|
async _processSpawnPoint(e, t) {
|
|
2118
2221
|
try {
|
|
2119
2222
|
let n = await this._spawnEntity(t, e);
|
|
2120
|
-
this._spawnedEntities.push(n), e.node.dispose(), this._log.debug(`Spawned entity '${t.entity}' at spawn point '${e.name}'`);
|
|
2223
|
+
this._spawnedEntities.push(n), this._applyDebugCollider(n, t.debugCollider), e.node.dispose(), this._log.debug(`Spawned entity '${t.entity}' at spawn point '${e.name}'`);
|
|
2121
2224
|
} catch (t) {
|
|
2122
2225
|
this._log.error(`Failed to spawn entity at spawn point '${e.name}':`, t);
|
|
2123
2226
|
}
|
|
2124
2227
|
}
|
|
2228
|
+
_applyDebugCollider(e, t) {
|
|
2229
|
+
let n = this.gameEngine.managers.entityManager.getDefinition(e.type)?.debugCollider, r = t ?? n;
|
|
2230
|
+
r && e.showCollider(r);
|
|
2231
|
+
}
|
|
2125
2232
|
async _spawnEntity(e, t) {
|
|
2126
2233
|
let n = {
|
|
2127
2234
|
...e.config,
|
|
2128
|
-
position:
|
|
2129
|
-
rotation:
|
|
2130
|
-
scaling:
|
|
2235
|
+
position: K(t.position),
|
|
2236
|
+
rotation: Ie(t.rotation),
|
|
2237
|
+
scaling: K(t.scaling)
|
|
2131
2238
|
}, r = await this.gameEngine.managers.entityManager.createEntity(e.entity, {
|
|
2132
2239
|
name: e.name,
|
|
2133
2240
|
tags: e.tags,
|
|
@@ -2139,7 +2246,7 @@ var Le = class {
|
|
|
2139
2246
|
if (!this._scene) return;
|
|
2140
2247
|
let n = this.gameEngine.managers.entityManager.getDefinition(e.type);
|
|
2141
2248
|
if (!n?.mesh) return;
|
|
2142
|
-
let r = n.mesh, i = this._scene, a = new
|
|
2249
|
+
let r = n.mesh, i = this._scene, a = new D(`entity-${e.id}`, i), o;
|
|
2143
2250
|
switch (r.source) {
|
|
2144
2251
|
case "box":
|
|
2145
2252
|
o = [b.CreateBox(`${e.type}-mesh`, {
|
|
@@ -2184,16 +2291,17 @@ var Le = class {
|
|
|
2184
2291
|
if (s?.color) {
|
|
2185
2292
|
let t = s.color;
|
|
2186
2293
|
if (s.type === "pbr") {
|
|
2187
|
-
let n = new
|
|
2294
|
+
let n = new S(`${e.type}-material`, i);
|
|
2188
2295
|
n.albedoColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive)), n.metallic = s.metallic ?? 0, n.roughness = s.roughness ?? 1;
|
|
2189
2296
|
for (let e of o) e.material = n;
|
|
2190
2297
|
} else {
|
|
2191
|
-
let n = new
|
|
2298
|
+
let n = new E(`${e.type}-material`, i);
|
|
2192
2299
|
n.diffuseColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive));
|
|
2193
2300
|
for (let e of o) e.material = n;
|
|
2194
2301
|
}
|
|
2195
2302
|
}
|
|
2196
|
-
|
|
2303
|
+
if (r.visible === !1) for (let e of o) e.isVisible = !1;
|
|
2304
|
+
let c = a.getDescendants(!1).filter((e) => e instanceof D);
|
|
2197
2305
|
for (let e of c) {
|
|
2198
2306
|
let t = this._getNormalizedMetadata(e);
|
|
2199
2307
|
t && Object.keys(t).length > 0 && (e.metadata = {
|
|
@@ -2211,14 +2319,14 @@ var Le = class {
|
|
|
2211
2319
|
try {
|
|
2212
2320
|
let n = {
|
|
2213
2321
|
...t?.config,
|
|
2214
|
-
position:
|
|
2322
|
+
position: K(e.node.position)
|
|
2215
2323
|
}, r = await this.gameEngine.managers.entityManager.createEntity(e.type, {
|
|
2216
2324
|
name: t?.name ?? e.node.name,
|
|
2217
2325
|
tags: t?.tags,
|
|
2218
2326
|
initialState: n,
|
|
2219
2327
|
node: e.node
|
|
2220
2328
|
});
|
|
2221
|
-
this._spawnedEntities.push(r), this._log.debug(`Created entity '${e.type}' for node '${e.node.name}'`);
|
|
2329
|
+
this._spawnedEntities.push(r), this._applyDebugCollider(r, t?.debugCollider), this._log.debug(`Created entity '${e.type}' for node '${e.node.name}'`);
|
|
2222
2330
|
} catch (t) {
|
|
2223
2331
|
this._log.error(`Failed to create entity for node '${e.node.name}':`, t);
|
|
2224
2332
|
}
|
|
@@ -2242,7 +2350,7 @@ var Le = class {
|
|
|
2242
2350
|
}
|
|
2243
2351
|
}
|
|
2244
2352
|
async onDeactivate() {
|
|
2245
|
-
for (let [e, t] of this._levelSounds) t.state ===
|
|
2353
|
+
for (let [e, t] of this._levelSounds) t.state === ae.Started && (this._playingSoundsBeforeDeactivate.add(e), t.pause());
|
|
2246
2354
|
}
|
|
2247
2355
|
async onActivate() {
|
|
2248
2356
|
for (let e of this._playingSoundsBeforeDeactivate) {
|
|
@@ -2263,7 +2371,7 @@ var Le = class {
|
|
|
2263
2371
|
for (let e of this._levelSounds.values()) e.dispose();
|
|
2264
2372
|
this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.$dispose();
|
|
2265
2373
|
}
|
|
2266
|
-
},
|
|
2374
|
+
}, He = class {
|
|
2267
2375
|
_eventBus;
|
|
2268
2376
|
_gameEngine = null;
|
|
2269
2377
|
_log;
|
|
@@ -2281,7 +2389,7 @@ var Le = class {
|
|
|
2281
2389
|
return this._propertyHandlers;
|
|
2282
2390
|
}
|
|
2283
2391
|
constructor(e, t) {
|
|
2284
|
-
this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new
|
|
2392
|
+
this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new N("LevelManager"), this._eventUnsubscribers.push(this._eventBus.subscribe("level:progress", (e) => {
|
|
2285
2393
|
this._handleProgress(e.payload);
|
|
2286
2394
|
})), this._eventUnsubscribers.push(this._eventBus.subscribe("level:complete", (e) => {
|
|
2287
2395
|
this._handleComplete(e.payload);
|
|
@@ -2316,7 +2424,7 @@ var Le = class {
|
|
|
2316
2424
|
if (!n) throw Error(`Level class '${e.class}' is not registered.`);
|
|
2317
2425
|
return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
|
|
2318
2426
|
}
|
|
2319
|
-
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new
|
|
2427
|
+
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new Ve(e, t);
|
|
2320
2428
|
}
|
|
2321
2429
|
registerLevelConfig(e) {
|
|
2322
2430
|
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}`);
|
|
@@ -2402,7 +2510,7 @@ var Le = class {
|
|
|
2402
2510
|
for (let e of this._loadedLevels.values()) await e.$dispose();
|
|
2403
2511
|
this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
|
|
2404
2512
|
}
|
|
2405
|
-
},
|
|
2513
|
+
}, Ue = class {
|
|
2406
2514
|
_audioEngine;
|
|
2407
2515
|
_channels = /* @__PURE__ */ new Map();
|
|
2408
2516
|
_masterMuted = !1;
|
|
@@ -2473,14 +2581,14 @@ var Le = class {
|
|
|
2473
2581
|
getChannels() {
|
|
2474
2582
|
return Array.from(this._channels.keys());
|
|
2475
2583
|
}
|
|
2476
|
-
},
|
|
2584
|
+
}, We = class {
|
|
2477
2585
|
_entityManager;
|
|
2478
2586
|
_levelManager;
|
|
2479
2587
|
_log;
|
|
2480
2588
|
_beforeSerializeHooks = [];
|
|
2481
2589
|
_afterDeserializeHooks = [];
|
|
2482
2590
|
constructor(e, t, n) {
|
|
2483
|
-
this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new
|
|
2591
|
+
this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new N("SaveManager"), this._log.info("SaveManager initialized");
|
|
2484
2592
|
}
|
|
2485
2593
|
onBeforeSerialize(e) {
|
|
2486
2594
|
this._beforeSerializeHooks.push(e);
|
|
@@ -2563,7 +2671,46 @@ var Le = class {
|
|
|
2563
2671
|
async $teardown() {
|
|
2564
2672
|
this._beforeSerializeHooks = [], this._afterDeserializeHooks = [], this._log.info("SaveManager torn down");
|
|
2565
2673
|
}
|
|
2566
|
-
},
|
|
2674
|
+
}, Ge = class {
|
|
2675
|
+
_viewer = null;
|
|
2676
|
+
_shown = /* @__PURE__ */ new Map();
|
|
2677
|
+
_materials = /* @__PURE__ */ new Map();
|
|
2678
|
+
showColliderForNode(e, t) {
|
|
2679
|
+
if (!e.physicsBody || this._shown.has(e)) return;
|
|
2680
|
+
let n = this._getViewer(e).showBody(e.physicsBody);
|
|
2681
|
+
if (!n) return;
|
|
2682
|
+
let r = { debugMesh: n };
|
|
2683
|
+
if (t) {
|
|
2684
|
+
let i = this._getColorMaterial(t, e);
|
|
2685
|
+
n.material = i, r.colorMaterial = i;
|
|
2686
|
+
}
|
|
2687
|
+
this._shown.set(e, r);
|
|
2688
|
+
}
|
|
2689
|
+
hideColliderForNode(e) {
|
|
2690
|
+
!this._shown.get(e) || !this._viewer || (e.physicsBody && this._viewer.hideBody(e.physicsBody), this._shown.delete(e));
|
|
2691
|
+
}
|
|
2692
|
+
hideAll() {
|
|
2693
|
+
for (let [e] of this._shown) this.hideColliderForNode(e);
|
|
2694
|
+
}
|
|
2695
|
+
isShown(e) {
|
|
2696
|
+
return this._shown.has(e);
|
|
2697
|
+
}
|
|
2698
|
+
async $teardown() {
|
|
2699
|
+
this.dispose();
|
|
2700
|
+
}
|
|
2701
|
+
dispose() {
|
|
2702
|
+
this._viewer &&= (this.hideAll(), this._viewer.dispose(), null), this._shown.clear();
|
|
2703
|
+
for (let e of this._materials.values()) e.dispose();
|
|
2704
|
+
this._materials.clear();
|
|
2705
|
+
}
|
|
2706
|
+
_getViewer(e) {
|
|
2707
|
+
return this._viewer ||= new pe(e.getScene()), this._viewer;
|
|
2708
|
+
}
|
|
2709
|
+
_getColorMaterial(e, t) {
|
|
2710
|
+
let n = this._materials.get(e);
|
|
2711
|
+
return n || (n = new E(`sage-collider-debug-${e}`, t.getScene()), n.emissiveColor = r.FromHexString(e), n.disableLighting = !0, n.wireframe = !0, this._materials.set(e, n), n);
|
|
2712
|
+
}
|
|
2713
|
+
}, Ke = class {
|
|
2567
2714
|
_keyboardDevice;
|
|
2568
2715
|
_keysState = {};
|
|
2569
2716
|
_onDeviceConnected;
|
|
@@ -2628,7 +2775,7 @@ var Le = class {
|
|
|
2628
2775
|
_notifyInputChanged(e) {
|
|
2629
2776
|
this._onInputChanged && this._onInputChanged(this._keyboardDevice, e);
|
|
2630
2777
|
}
|
|
2631
|
-
},
|
|
2778
|
+
}, qe = class {
|
|
2632
2779
|
_targetElement;
|
|
2633
2780
|
_mouseDevice;
|
|
2634
2781
|
_buttonState = {};
|
|
@@ -2747,7 +2894,7 @@ var Le = class {
|
|
|
2747
2894
|
_notifyInputChanged(e) {
|
|
2748
2895
|
this._onInputChanged && this._onInputChanged(this._mouseDevice, e);
|
|
2749
2896
|
}
|
|
2750
|
-
},
|
|
2897
|
+
}, Je = class {
|
|
2751
2898
|
_gamepadDevices = {};
|
|
2752
2899
|
_buttonStates = {};
|
|
2753
2900
|
_axesStates = {};
|
|
@@ -2881,14 +3028,14 @@ var Le = class {
|
|
|
2881
3028
|
_notifyInputChanged(e, t) {
|
|
2882
3029
|
this._onInputChanged && this._onInputChanged(e, t);
|
|
2883
3030
|
}
|
|
2884
|
-
},
|
|
3031
|
+
}, Ye = class {
|
|
2885
3032
|
_eventBus;
|
|
2886
3033
|
_keyboardRA;
|
|
2887
3034
|
_mouseRA;
|
|
2888
3035
|
_gamepadRA;
|
|
2889
3036
|
_log;
|
|
2890
3037
|
constructor(e, t, n) {
|
|
2891
|
-
this._eventBus = e, this._log = n?.getLogger("UserInputManager") || new
|
|
3038
|
+
this._eventBus = e, this._log = n?.getLogger("UserInputManager") || new N("UserInputManager"), this._log.info("Initializing UserInputManager"), this._log.debug("Initializing input resource access classes"), this._keyboardRA = new Ke(), this._mouseRA = new qe(t), this._gamepadRA = new Je(), 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");
|
|
2892
3039
|
}
|
|
2893
3040
|
_publishDeviceConnected(e) {
|
|
2894
3041
|
this._log.debug(`Device connected: ${e.id} (${e.name})`), this._eventBus.publish({
|
|
@@ -2941,18 +3088,18 @@ var Le = class {
|
|
|
2941
3088
|
};
|
|
2942
3089
|
//#endregion
|
|
2943
3090
|
//#region src/utils/graphics.ts
|
|
2944
|
-
async function
|
|
2945
|
-
let n = new
|
|
3091
|
+
async function Xe(e, t) {
|
|
3092
|
+
let n = new le(e, t);
|
|
2946
3093
|
return await n.initAsync(), n;
|
|
2947
3094
|
}
|
|
2948
|
-
function
|
|
3095
|
+
function J(e, t) {
|
|
2949
3096
|
return new l(e, t.antialias, t.options, t.adaptToDeviceRatio);
|
|
2950
3097
|
}
|
|
2951
|
-
function
|
|
3098
|
+
function Ze(e) {
|
|
2952
3099
|
return new x(e);
|
|
2953
3100
|
}
|
|
2954
|
-
async function
|
|
2955
|
-
if (e === null) return console.debug("Using Null Engine"),
|
|
3101
|
+
async function Qe(e, t, n = !1) {
|
|
3102
|
+
if (e === null) return console.debug("Using Null Engine"), Ze(t);
|
|
2956
3103
|
if (n) if ("options" in t) {
|
|
2957
3104
|
let e = t;
|
|
2958
3105
|
t = {
|
|
@@ -2967,32 +3114,32 @@ async function Ye(e, t, n = !1) {
|
|
|
2967
3114
|
useLargeWorldRendering: !0
|
|
2968
3115
|
};
|
|
2969
3116
|
let r = t.engine || "auto";
|
|
2970
|
-
if (r === "webgpu") if (
|
|
2971
|
-
return console.debug("Using forced WebGPU engine"), await
|
|
3117
|
+
if (r === "webgpu") if (De()) try {
|
|
3118
|
+
return console.debug("Using forced WebGPU engine"), await Xe(e, t);
|
|
2972
3119
|
} catch (e) {
|
|
2973
3120
|
throw console.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
|
|
2974
3121
|
}
|
|
2975
3122
|
else throw Error("WebGPU was forced but is not available in this browser.");
|
|
2976
|
-
if (r === "webgl") return console.debug("Using forced WebGL engine"),
|
|
2977
|
-
if (
|
|
2978
|
-
return console.debug("Using WebGPU"),
|
|
3123
|
+
if (r === "webgl") return console.debug("Using forced WebGL engine"), J(e, t);
|
|
3124
|
+
if (De()) try {
|
|
3125
|
+
return console.debug("Using WebGPU"), Xe(e, t).catch((n) => (console.warn("WebGPU initialization failed, falling back to WebGL:", n), J(e, t)));
|
|
2979
3126
|
} catch (e) {
|
|
2980
3127
|
console.warn("WebGPU initialization failed, falling back to WebGL:", e);
|
|
2981
3128
|
}
|
|
2982
3129
|
else console.warn("WebGPU not supported, falling back to WebGL.");
|
|
2983
|
-
return console.debug("Using WebGL"),
|
|
3130
|
+
return console.debug("Using WebGL"), J(e, t);
|
|
2984
3131
|
}
|
|
2985
3132
|
//#endregion
|
|
2986
3133
|
//#region src/utils/physics.ts
|
|
2987
|
-
async function
|
|
2988
|
-
return await
|
|
3134
|
+
async function $e() {
|
|
3135
|
+
return await me();
|
|
2989
3136
|
}
|
|
2990
|
-
function
|
|
3137
|
+
function et(e) {
|
|
2991
3138
|
return new p(!0, e);
|
|
2992
3139
|
}
|
|
2993
3140
|
//#endregion
|
|
2994
3141
|
//#region src/utils/raycast.ts
|
|
2995
|
-
var
|
|
3142
|
+
var tt = class {
|
|
2996
3143
|
_entityManager;
|
|
2997
3144
|
constructor(e) {
|
|
2998
3145
|
this._entityManager = e;
|
|
@@ -3058,7 +3205,7 @@ var Qe = class {
|
|
|
3058
3205
|
pickingInfo: e
|
|
3059
3206
|
};
|
|
3060
3207
|
}
|
|
3061
|
-
},
|
|
3208
|
+
}, nt = class {
|
|
3062
3209
|
_nextId = 0;
|
|
3063
3210
|
_delays = [];
|
|
3064
3211
|
_intervals = [];
|
|
@@ -3113,21 +3260,120 @@ var Qe = class {
|
|
|
3113
3260
|
for (let t of this._intervals) for (t.elapsed += e; t.elapsed >= t.periodMs;) t.callback(), t.elapsed -= t.periodMs;
|
|
3114
3261
|
for (let t of this._cooldowns) t.remaining > 0 && (t.remaining = Math.max(0, t.remaining - e));
|
|
3115
3262
|
}
|
|
3116
|
-
}
|
|
3263
|
+
};
|
|
3264
|
+
//#endregion
|
|
3265
|
+
//#region src/utils/entityProxy.ts
|
|
3266
|
+
function rt(e) {
|
|
3267
|
+
return new Proxy(e, { get(e, t) {
|
|
3268
|
+
if (typeof t == "symbol") return Reflect.get(e, t);
|
|
3269
|
+
if (t in e) {
|
|
3270
|
+
let n = Reflect.get(e, t);
|
|
3271
|
+
return typeof n == "function" ? n.bind(e) : n;
|
|
3272
|
+
}
|
|
3273
|
+
return e.getByName(t);
|
|
3274
|
+
} });
|
|
3275
|
+
}
|
|
3276
|
+
//#endregion
|
|
3277
|
+
//#region src/debug/builtins.ts
|
|
3278
|
+
function it(e, t) {
|
|
3279
|
+
return typeof e == "string" ? t.managers.entityManager.getByName(e) : e;
|
|
3280
|
+
}
|
|
3281
|
+
function at(e, t) {
|
|
3282
|
+
let n = t.managers.entityManager;
|
|
3283
|
+
if (e === void 0) return [...n.getAllEntities()];
|
|
3284
|
+
if (typeof e != "string") return [e];
|
|
3285
|
+
let r = n.getByName(e);
|
|
3286
|
+
if (r) return [r];
|
|
3287
|
+
let i = n.getByType(e);
|
|
3288
|
+
return i.length > 0 ? i : (console.warn(`[sage] No entity found with name or type "${e}"`), []);
|
|
3289
|
+
}
|
|
3290
|
+
function ot(e, t) {
|
|
3291
|
+
let n = t.managers.entityManager, r = t.managers.gameManager, i = t.managers.levelManager, a = [];
|
|
3292
|
+
e.expose("engine", t), e.expose("events", t.eventBus), e.expose("physics", t.physics), e.expose("colliders", t.debug.colliders), e.expose("entities", rt(n)), e.expose("level", { get: () => i.currentLevel }), e.expose("scene", { get: () => i.currentLevel?.scene ?? null }), e.expose("tp", (e, n, r, i) => {
|
|
3293
|
+
let a = it(e, t);
|
|
3294
|
+
if (!a) {
|
|
3295
|
+
console.warn(`[sage] Entity not found: ${e}`);
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3298
|
+
if (!a.node) {
|
|
3299
|
+
console.warn(`[sage] Entity "${a.name ?? a.id}" has no node`);
|
|
3300
|
+
return;
|
|
3301
|
+
}
|
|
3302
|
+
a.node.position.x = n, a.node.position.y = r, a.node.position.z = i, console.log(`[sage] Teleported "${a.name ?? a.id}" to (${n}, ${r}, ${i})`);
|
|
3303
|
+
}), e.expose("spawn", async (e, t, r, i) => {
|
|
3304
|
+
let a = await n.createEntity(e, { initialState: { position: {
|
|
3305
|
+
x: t,
|
|
3306
|
+
y: r,
|
|
3307
|
+
z: i
|
|
3308
|
+
} } });
|
|
3309
|
+
return console.log(`[sage] Spawned "${e}" (${a.id}) at (${t}, ${r}, ${i})`), a;
|
|
3310
|
+
}), e.expose("list", (e) => {
|
|
3311
|
+
let t;
|
|
3312
|
+
t = e ? n.getByType(e) : [...n.getAllEntities()];
|
|
3313
|
+
let r = t.map((e) => ({
|
|
3314
|
+
id: e.id,
|
|
3315
|
+
type: e.type,
|
|
3316
|
+
name: e.name ?? "(unnamed)",
|
|
3317
|
+
node: e.node?.name ?? "(no node)"
|
|
3318
|
+
}));
|
|
3319
|
+
return console.table(r), t;
|
|
3320
|
+
}), e.expose("inspect", (e) => {
|
|
3321
|
+
let n = it(e, t);
|
|
3322
|
+
if (!n) {
|
|
3323
|
+
console.warn(`[sage] Entity not found: ${e}`);
|
|
3324
|
+
return;
|
|
3325
|
+
}
|
|
3326
|
+
let r = {
|
|
3327
|
+
id: n.id,
|
|
3328
|
+
type: n.type,
|
|
3329
|
+
name: n.name,
|
|
3330
|
+
state: n.state,
|
|
3331
|
+
behaviors: n.behaviors.map((e) => e.name),
|
|
3332
|
+
node: n.node?.name ?? null,
|
|
3333
|
+
position: n.node?.position ?? null
|
|
3334
|
+
};
|
|
3335
|
+
return console.log("[sage] Entity info:", r), r;
|
|
3336
|
+
}), e.expose("showColliders", (e) => {
|
|
3337
|
+
let n = at(e, t);
|
|
3338
|
+
for (let e of n) e.showCollider();
|
|
3339
|
+
console.log(`[sage] Showing colliders for ${n.length} entity(s)`);
|
|
3340
|
+
}), e.expose("hideColliders", (e) => {
|
|
3341
|
+
let n = at(e, t);
|
|
3342
|
+
for (let e of n) e.hideCollider();
|
|
3343
|
+
console.log(`[sage] Hiding colliders for ${n.length} entity(s)`);
|
|
3344
|
+
}), e.expose("logEvents", (e) => {
|
|
3345
|
+
let n = e ?? "*", r = t.eventBus.subscribe(n, (e) => {
|
|
3346
|
+
console.log(`[sage] Event: ${e.type}`, e.payload);
|
|
3347
|
+
});
|
|
3348
|
+
return a.push(r), console.log(`[sage] Logging events matching "${n}"`), r;
|
|
3349
|
+
}), e.expose("stopLogging", () => {
|
|
3350
|
+
for (let e of a) e();
|
|
3351
|
+
console.log(`[sage] Stopped ${a.length} event logger(s)`), a.length = 0;
|
|
3352
|
+
}), e.expose("pause", () => {
|
|
3353
|
+
r.pause("debug console"), console.log("[sage] Game paused");
|
|
3354
|
+
}), e.expose("resume", () => {
|
|
3355
|
+
r.resume("debug console"), console.log("[sage] Game resumed");
|
|
3356
|
+
}), e.expose("slow", (e) => {
|
|
3357
|
+
t.renderEngine.timeStep = 1 / 60 / e, console.log(`[sage] Time scale set to ${e}x (timeStep=${1 / 60 / e})`);
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
//#endregion
|
|
3361
|
+
//#region src/interfaces/logger.ts
|
|
3362
|
+
var st = [
|
|
3117
3363
|
"trace",
|
|
3118
3364
|
"debug",
|
|
3119
3365
|
"info",
|
|
3120
3366
|
"warn",
|
|
3121
3367
|
"error",
|
|
3122
3368
|
"none"
|
|
3123
|
-
],
|
|
3369
|
+
], ct = class extends G {
|
|
3124
3370
|
name = "sound";
|
|
3125
3371
|
eventSubscriptions = [];
|
|
3126
3372
|
_sounds = /* @__PURE__ */ new Map();
|
|
3127
3373
|
_initialized = !1;
|
|
3128
3374
|
_audioManager = null;
|
|
3129
3375
|
_node = null;
|
|
3130
|
-
_log = new
|
|
3376
|
+
_log = new N("SoundBehavior");
|
|
3131
3377
|
onNodeAttached(e, t) {
|
|
3132
3378
|
if (this._initialized) return;
|
|
3133
3379
|
if (this._node = e, this._initialized = !0, this._log = t.logger.getLogger("SoundBehavior"), t.managers.audioManager) this._audioManager = t.managers.audioManager;
|
|
@@ -3189,7 +3435,7 @@ var Qe = class {
|
|
|
3189
3435
|
} else for (let t of this._sounds.values()) t.volume = e;
|
|
3190
3436
|
}
|
|
3191
3437
|
isPlaying(e) {
|
|
3192
|
-
return this._getSound(e)?.state ===
|
|
3438
|
+
return this._getSound(e)?.state === ae.Started;
|
|
3193
3439
|
}
|
|
3194
3440
|
getSoundNames() {
|
|
3195
3441
|
return Array.from(this._sounds.keys());
|
|
@@ -3210,7 +3456,7 @@ var Qe = class {
|
|
|
3210
3456
|
if (e) return this._sounds.get(e);
|
|
3211
3457
|
if (this._sounds.size === 1) return this._sounds.values().next().value;
|
|
3212
3458
|
}
|
|
3213
|
-
},
|
|
3459
|
+
}, Y = class {
|
|
3214
3460
|
_currentState;
|
|
3215
3461
|
transitions = /* @__PURE__ */ new Map();
|
|
3216
3462
|
wildcardTransitions = /* @__PURE__ */ new Map();
|
|
@@ -3265,13 +3511,13 @@ var Qe = class {
|
|
|
3265
3511
|
}
|
|
3266
3512
|
});
|
|
3267
3513
|
}
|
|
3268
|
-
},
|
|
3514
|
+
}, lt = class extends G {
|
|
3269
3515
|
name = "stateMachine";
|
|
3270
3516
|
eventSubscriptions = [];
|
|
3271
3517
|
stateMachine;
|
|
3272
3518
|
stateKey;
|
|
3273
3519
|
constructor() {
|
|
3274
|
-
super(), this.stateMachine = new
|
|
3520
|
+
super(), this.stateMachine = new Y(""), this.stateKey = "";
|
|
3275
3521
|
}
|
|
3276
3522
|
get currentState() {
|
|
3277
3523
|
return this.stateMachine.currentState;
|
|
@@ -3284,64 +3530,75 @@ var Qe = class {
|
|
|
3284
3530
|
}
|
|
3285
3531
|
static create(e) {
|
|
3286
3532
|
let { initialState: t, stateKey: n, transitions: r, wildcardTransitions: i } = e;
|
|
3287
|
-
class a extends
|
|
3533
|
+
class a extends lt {
|
|
3288
3534
|
constructor() {
|
|
3289
|
-
super(), this.stateKey = n, this.stateMachine = new
|
|
3535
|
+
super(), this.stateKey = n, this.stateMachine = new Y(t);
|
|
3290
3536
|
for (let e of r) this.stateMachine.addTransition(e.from, e.to, e.guard);
|
|
3291
3537
|
if (i) for (let e of i) this.stateMachine.addTransitionFromAny(e.to, e.guard);
|
|
3292
3538
|
}
|
|
3293
3539
|
}
|
|
3294
3540
|
return a;
|
|
3295
3541
|
}
|
|
3296
|
-
},
|
|
3297
|
-
function
|
|
3298
|
-
let r = e.
|
|
3299
|
-
|
|
3542
|
+
}, X = new N("ColliderHandler");
|
|
3543
|
+
function ut(e) {
|
|
3544
|
+
let { min: t, max: n } = e.getHierarchyBoundingVectors(!0), r = n.subtract(t), i = t.add(n).scale(.5).subtract(e.absolutePosition), a = e.absoluteRotationQuaternion, o = T.Inverse(a), s = new O();
|
|
3545
|
+
return i.rotateByQuaternionToRef(o, s), {
|
|
3546
|
+
extents: r,
|
|
3547
|
+
center: s
|
|
3548
|
+
};
|
|
3549
|
+
}
|
|
3550
|
+
function Z(e, t, n) {
|
|
3551
|
+
let r = e.getScene(), i = { mass: n };
|
|
3552
|
+
if (!(e instanceof y) && (t === w.BOX || t === w.SPHERE)) {
|
|
3553
|
+
let { extents: n, center: r } = ut(e);
|
|
3554
|
+
i.center = r, t === w.BOX ? i.extents = n : i.radius = Math.max(n.x, n.y, n.z) / 2;
|
|
3555
|
+
}
|
|
3556
|
+
new C(e, t, i, r);
|
|
3300
3557
|
}
|
|
3301
|
-
function
|
|
3558
|
+
function dt(e, t) {
|
|
3302
3559
|
let n = e.getChildMeshes().find((e) => e.metadata?.collider_mesh === !0);
|
|
3303
|
-
n instanceof y ? (n.isVisible = !1,
|
|
3560
|
+
n instanceof y ? (n.isVisible = !1, Z(n, w.MESH, t)) : Z(e, w.MESH, t);
|
|
3304
3561
|
}
|
|
3305
|
-
function
|
|
3562
|
+
function ft(t) {
|
|
3306
3563
|
t.registerPropertyHandler("collider", (t, n, r, i) => {
|
|
3307
3564
|
let a = n;
|
|
3308
|
-
if (
|
|
3565
|
+
if (X.debug(`Processing collider: ${t.name} -> ${a} (isMesh: ${t instanceof y})`), !r.scene) throw Error("Scene not available for collider handler");
|
|
3309
3566
|
if (!(t instanceof y) && a === "mesh") {
|
|
3310
|
-
|
|
3567
|
+
X.warn(`Skipping mesh collider for ${t.name}: not a Mesh instance`);
|
|
3311
3568
|
return;
|
|
3312
3569
|
}
|
|
3313
3570
|
let o = t.metadata?.collider_mass ?? 0;
|
|
3314
3571
|
switch (a) {
|
|
3315
3572
|
case "box":
|
|
3316
|
-
|
|
3573
|
+
Z(t, w.BOX, o);
|
|
3317
3574
|
break;
|
|
3318
3575
|
case "sphere":
|
|
3319
|
-
|
|
3576
|
+
Z(t, w.SPHERE, o);
|
|
3320
3577
|
break;
|
|
3321
3578
|
case "mesh":
|
|
3322
|
-
|
|
3579
|
+
dt(t, o);
|
|
3323
3580
|
break;
|
|
3324
3581
|
case "none":
|
|
3325
3582
|
t instanceof e && (t.checkCollisions = !1);
|
|
3326
3583
|
break;
|
|
3327
|
-
default:
|
|
3584
|
+
default: X.warn(`Unknown collider type: ${a}`);
|
|
3328
3585
|
}
|
|
3329
3586
|
t.metadata?.collider_kinematic && t instanceof e && t.physicsBody && (t.physicsBody.disablePreStep = !1);
|
|
3330
3587
|
});
|
|
3331
3588
|
}
|
|
3332
3589
|
//#endregion
|
|
3333
3590
|
//#region src/handlers/lod.ts
|
|
3334
|
-
var
|
|
3335
|
-
function
|
|
3591
|
+
var pt = new N("LodHandler");
|
|
3592
|
+
function mt(e) {
|
|
3336
3593
|
return e.split(",").map((e) => parseFloat(e.trim())).filter((e) => !isNaN(e));
|
|
3337
3594
|
}
|
|
3338
|
-
function
|
|
3595
|
+
function ht(e) {
|
|
3339
3596
|
e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
|
|
3340
3597
|
let i = t;
|
|
3341
3598
|
if (!(e instanceof y)) return;
|
|
3342
|
-
let a =
|
|
3599
|
+
let a = mt(i);
|
|
3343
3600
|
if (a.length === 0) {
|
|
3344
|
-
|
|
3601
|
+
pt.warn(`Invalid lod_distances value: ${i}`);
|
|
3345
3602
|
return;
|
|
3346
3603
|
}
|
|
3347
3604
|
let o = e.getChildMeshes(!0), s = Math.min(a.length, o.length);
|
|
@@ -3352,14 +3609,14 @@ function st(e) {
|
|
|
3352
3609
|
}
|
|
3353
3610
|
//#endregion
|
|
3354
3611
|
//#region src/handlers/occluder.ts
|
|
3355
|
-
function
|
|
3612
|
+
function gt(e) {
|
|
3356
3613
|
e.registerPropertyHandler("occluder", (e, t, n, r) => {
|
|
3357
3614
|
t && e instanceof y && (e.isOccluder = !0, e.isVisible = !1);
|
|
3358
3615
|
});
|
|
3359
3616
|
}
|
|
3360
3617
|
//#endregion
|
|
3361
3618
|
//#region src/utils/metadata.ts
|
|
3362
|
-
function
|
|
3619
|
+
function _t(e, t) {
|
|
3363
3620
|
let n = {}, r = `${t}_`;
|
|
3364
3621
|
for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
|
|
3365
3622
|
let e = t.slice(r.length);
|
|
@@ -3369,14 +3626,14 @@ function ct(e, t) {
|
|
|
3369
3626
|
}
|
|
3370
3627
|
//#endregion
|
|
3371
3628
|
//#region src/handlers/sound.ts
|
|
3372
|
-
var
|
|
3373
|
-
function
|
|
3629
|
+
var vt = new N("SoundHandler");
|
|
3630
|
+
function yt(e) {
|
|
3374
3631
|
e.registerPropertyHandler("sound", (e, t, n, r) => {
|
|
3375
3632
|
let i = t;
|
|
3376
3633
|
if (!n.scene) throw Error("Scene not available for sound handler");
|
|
3377
|
-
let a =
|
|
3634
|
+
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.managers.audioManager;
|
|
3378
3635
|
if (!f) {
|
|
3379
|
-
|
|
3636
|
+
vt.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
|
|
3380
3637
|
return;
|
|
3381
3638
|
}
|
|
3382
3639
|
f.createSound(`${e.name}_sound`, i, d, {
|
|
@@ -3389,13 +3646,13 @@ function ut(e) {
|
|
|
3389
3646
|
}).then((t) => {
|
|
3390
3647
|
c && t.spatial.attach(e);
|
|
3391
3648
|
}).catch((t) => {
|
|
3392
|
-
|
|
3649
|
+
vt.error(`Failed to create sound for node "${e.name}": ${t}`);
|
|
3393
3650
|
});
|
|
3394
3651
|
});
|
|
3395
3652
|
}
|
|
3396
3653
|
//#endregion
|
|
3397
3654
|
//#region src/handlers/trigger.ts
|
|
3398
|
-
function
|
|
3655
|
+
function Q(e, n, r, i, a) {
|
|
3399
3656
|
let o = a === "enter" ? t.OnIntersectionEnterTrigger : t.OnIntersectionExitTrigger, s = `trigger:${a}`;
|
|
3400
3657
|
e.registerAction(new u({
|
|
3401
3658
|
trigger: o,
|
|
@@ -3410,10 +3667,10 @@ function dt(e, n, r, i, a) {
|
|
|
3410
3667
|
});
|
|
3411
3668
|
}));
|
|
3412
3669
|
}
|
|
3413
|
-
function
|
|
3414
|
-
|
|
3670
|
+
function bt(e, t, n, r) {
|
|
3671
|
+
Q(e, t, n, r, "enter"), Q(e, t, n, r, "exit");
|
|
3415
3672
|
}
|
|
3416
|
-
function
|
|
3673
|
+
function xt(n) {
|
|
3417
3674
|
n.registerPropertyHandler("trigger", (n, r, i, a) => {
|
|
3418
3675
|
let o = r, s = i.scene;
|
|
3419
3676
|
if (!s) throw Error("Scene not available for trigger handler");
|
|
@@ -3422,9 +3679,9 @@ function pt(n) {
|
|
|
3422
3679
|
n.isVisible = !1, n.checkCollisions = !0;
|
|
3423
3680
|
let l = n.actionManager ?? new t(s);
|
|
3424
3681
|
n.actionManager = l;
|
|
3425
|
-
for (let e of s.meshes) e !== n && !e.metadata?.trigger &&
|
|
3682
|
+
for (let e of s.meshes) e !== n && !e.metadata?.trigger && bt(l, o, c, e);
|
|
3426
3683
|
let u = s.onNewMeshAddedObservable.add((e) => {
|
|
3427
|
-
e !== n && !e.metadata?.trigger &&
|
|
3684
|
+
e !== n && !e.metadata?.trigger && bt(l, o, c, e);
|
|
3428
3685
|
});
|
|
3429
3686
|
n.onDisposeObservable.add(() => {
|
|
3430
3687
|
s.onNewMeshAddedObservable.remove(u);
|
|
@@ -3433,7 +3690,7 @@ function pt(n) {
|
|
|
3433
3690
|
}
|
|
3434
3691
|
//#endregion
|
|
3435
3692
|
//#region src/handlers/visible.ts
|
|
3436
|
-
function
|
|
3693
|
+
function $(t) {
|
|
3437
3694
|
t.registerPropertyHandler("visible", (t, n, r, i) => {
|
|
3438
3695
|
if (!(t instanceof e)) return;
|
|
3439
3696
|
let a = !0;
|
|
@@ -3442,39 +3699,41 @@ function mt(t) {
|
|
|
3442
3699
|
}
|
|
3443
3700
|
//#endregion
|
|
3444
3701
|
//#region src/handlers/index.ts
|
|
3445
|
-
function
|
|
3446
|
-
|
|
3702
|
+
function St(e) {
|
|
3703
|
+
ft(e), ht(e), gt(e), yt(e), xt(e), $(e);
|
|
3447
3704
|
}
|
|
3448
3705
|
//#endregion
|
|
3449
3706
|
//#region src/sage.ts
|
|
3450
|
-
async function
|
|
3451
|
-
let r = new
|
|
3452
|
-
i.info(`Initializing SAGE Game Engine v${
|
|
3453
|
-
let a = await
|
|
3707
|
+
async function Ct(e, t, n = {}) {
|
|
3708
|
+
let r = new P(n.logLevel || "debug"), i = r.getLogger("SAGE");
|
|
3709
|
+
i.info(`Initializing SAGE Game Engine v${k}...`), i.debug("Creating rendering engine...");
|
|
3710
|
+
let a = await Qe(e, {
|
|
3454
3711
|
antialias: !0,
|
|
3455
3712
|
adaptToDeviceRatio: !0,
|
|
3456
3713
|
...n.renderOptions
|
|
3457
3714
|
}, n.largeWorldRendering ?? !1);
|
|
3458
3715
|
i.debug("Creating physics engine...");
|
|
3459
|
-
let o = await
|
|
3716
|
+
let o = await $e(), s = et(o);
|
|
3460
3717
|
i.debug("Creating event bus...");
|
|
3461
|
-
let c = new
|
|
3718
|
+
let c = new F(r);
|
|
3462
3719
|
i.debug("Creating scene engine...");
|
|
3463
|
-
let l = new
|
|
3720
|
+
let l = new L(e, a, o, r);
|
|
3464
3721
|
i.debug("Creating managers...");
|
|
3465
|
-
let u = new
|
|
3722
|
+
let u = new R(c, l, r), d = new Ye(c, e, r), f = new Ee(c, r), p = new Me(c, r, f), m = new He(c, r), h = new We(p, m, r), g = new Oe(a, c, p, d, m, r), _ = null;
|
|
3723
|
+
n.debug !== !1 && (i.debug("Creating debug console..."), _ = new he((typeof n.debug == "object" ? n.debug.namespace : void 0) ?? "sage")), i.debug("Creating collider debug manager...");
|
|
3724
|
+
let v = new Ge();
|
|
3466
3725
|
i.debug("Creating raycast helper...");
|
|
3467
|
-
let
|
|
3726
|
+
let y = new tt(p);
|
|
3468
3727
|
i.debug("Creating game timer...");
|
|
3469
|
-
let
|
|
3470
|
-
g.registerFrameCallback((e) =>
|
|
3471
|
-
let
|
|
3472
|
-
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."),
|
|
3728
|
+
let b = new nt();
|
|
3729
|
+
g.registerFrameCallback((e) => b.tick(e * 1e3));
|
|
3730
|
+
let x, S;
|
|
3731
|
+
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), x = new I(r), await x.initialize(), i.debug("Creating audio manager..."), S = new Ue(x, r), await S.initialize(n.audioChannels)), i.info(`SAGE Game Engine v${k} initialized successfully.`), i.debug("Loading entities...");
|
|
3473
3732
|
for (let e of t) p.registerEntityDefinition(e);
|
|
3474
3733
|
if (i.debug("Registering default input bindings..."), n.bindings) for (let e of n.bindings) f.registerBinding(e);
|
|
3475
|
-
let
|
|
3734
|
+
let C = new A(e, a, s, c, r, y, b, {
|
|
3476
3735
|
sceneEngine: l,
|
|
3477
|
-
audioEngine:
|
|
3736
|
+
audioEngine: x
|
|
3478
3737
|
}, {
|
|
3479
3738
|
assetManager: u,
|
|
3480
3739
|
bindingManager: f,
|
|
@@ -3483,11 +3742,17 @@ async function gt(e, t, n = {}) {
|
|
|
3483
3742
|
inputManager: d,
|
|
3484
3743
|
levelManager: m,
|
|
3485
3744
|
saveManager: h,
|
|
3486
|
-
audioManager:
|
|
3487
|
-
}, n.largeWorldRendering ?? !1
|
|
3488
|
-
|
|
3745
|
+
audioManager: S
|
|
3746
|
+
}, n.largeWorldRendering ?? !1, {
|
|
3747
|
+
colliders: v,
|
|
3748
|
+
console: _,
|
|
3749
|
+
expose: (e, t) => {
|
|
3750
|
+
_?.expose(e, t);
|
|
3751
|
+
}
|
|
3752
|
+
});
|
|
3753
|
+
return p.$setGameEngine(C), m.$setGameEngine(C), _ && ot(_, C), C;
|
|
3489
3754
|
}
|
|
3490
3755
|
//#endregion
|
|
3491
|
-
export {
|
|
3756
|
+
export { R as AssetManager, I as AudioEngine, Ue as AudioManager, Ge as ColliderDebugManager, j as ConsoleBackend, he as DebugConsole, A as GameEngine, je as GameEntity, G as GameEntityBehavior, F as GameEventBus, Ve as GameLevel, nt as GameTimer, ze as Level, st as LogLevels, P as LoggingUtility, M as NullBackend, Be as OutlineManager, tt as RaycastHelper, N as SAGELogger, We as SaveManager, L as SceneEngine, ct as SoundBehavior, Y as StateMachine, lt as StateMachineBehavior, k as VERSION, Fe as applyPostProcessing, z as bindingTypes, _t as collectPrefixedProperties, rt as createEntityProxy, Ct as createGameEngine, Ae as generateId, Re as getCanonicalTransform, V as isGamepadState, _e as isKeyboardState, B as isMouseState, St as registerAllPropertyHandlers, ft as registerColliderHandler, ht as registerLodHandler, gt as registerOccluderHandler, yt as registerSoundHandler, xt as registerTriggerHandler, $ as registerVisibleHandler, Ie as toQuatObject, Le as toQuaternion, K as toVec3Object, q as toVector3, ge as validDeviceTypes };
|
|
3492
3757
|
|
|
3493
3758
|
//# sourceMappingURL=sage.es.js.map
|