@skewedaspect/sage 0.9.2 → 0.9.3
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/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 +3 -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 +471 -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.3", 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,16 @@ 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
|
-
let c = a.getDescendants(!1).filter((e) => e instanceof
|
|
2303
|
+
let c = a.getDescendants(!1).filter((e) => e instanceof D);
|
|
2197
2304
|
for (let e of c) {
|
|
2198
2305
|
let t = this._getNormalizedMetadata(e);
|
|
2199
2306
|
t && Object.keys(t).length > 0 && (e.metadata = {
|
|
@@ -2211,14 +2318,14 @@ var Le = class {
|
|
|
2211
2318
|
try {
|
|
2212
2319
|
let n = {
|
|
2213
2320
|
...t?.config,
|
|
2214
|
-
position:
|
|
2321
|
+
position: K(e.node.position)
|
|
2215
2322
|
}, r = await this.gameEngine.managers.entityManager.createEntity(e.type, {
|
|
2216
2323
|
name: t?.name ?? e.node.name,
|
|
2217
2324
|
tags: t?.tags,
|
|
2218
2325
|
initialState: n,
|
|
2219
2326
|
node: e.node
|
|
2220
2327
|
});
|
|
2221
|
-
this._spawnedEntities.push(r), this._log.debug(`Created entity '${e.type}' for node '${e.node.name}'`);
|
|
2328
|
+
this._spawnedEntities.push(r), this._applyDebugCollider(r, t?.debugCollider), this._log.debug(`Created entity '${e.type}' for node '${e.node.name}'`);
|
|
2222
2329
|
} catch (t) {
|
|
2223
2330
|
this._log.error(`Failed to create entity for node '${e.node.name}':`, t);
|
|
2224
2331
|
}
|
|
@@ -2242,7 +2349,7 @@ var Le = class {
|
|
|
2242
2349
|
}
|
|
2243
2350
|
}
|
|
2244
2351
|
async onDeactivate() {
|
|
2245
|
-
for (let [e, t] of this._levelSounds) t.state ===
|
|
2352
|
+
for (let [e, t] of this._levelSounds) t.state === ae.Started && (this._playingSoundsBeforeDeactivate.add(e), t.pause());
|
|
2246
2353
|
}
|
|
2247
2354
|
async onActivate() {
|
|
2248
2355
|
for (let e of this._playingSoundsBeforeDeactivate) {
|
|
@@ -2263,7 +2370,7 @@ var Le = class {
|
|
|
2263
2370
|
for (let e of this._levelSounds.values()) e.dispose();
|
|
2264
2371
|
this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.$dispose();
|
|
2265
2372
|
}
|
|
2266
|
-
},
|
|
2373
|
+
}, He = class {
|
|
2267
2374
|
_eventBus;
|
|
2268
2375
|
_gameEngine = null;
|
|
2269
2376
|
_log;
|
|
@@ -2281,7 +2388,7 @@ var Le = class {
|
|
|
2281
2388
|
return this._propertyHandlers;
|
|
2282
2389
|
}
|
|
2283
2390
|
constructor(e, t) {
|
|
2284
|
-
this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new
|
|
2391
|
+
this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new N("LevelManager"), this._eventUnsubscribers.push(this._eventBus.subscribe("level:progress", (e) => {
|
|
2285
2392
|
this._handleProgress(e.payload);
|
|
2286
2393
|
})), this._eventUnsubscribers.push(this._eventBus.subscribe("level:complete", (e) => {
|
|
2287
2394
|
this._handleComplete(e.payload);
|
|
@@ -2316,7 +2423,7 @@ var Le = class {
|
|
|
2316
2423
|
if (!n) throw Error(`Level class '${e.class}' is not registered.`);
|
|
2317
2424
|
return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
|
|
2318
2425
|
}
|
|
2319
|
-
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new
|
|
2426
|
+
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new Ve(e, t);
|
|
2320
2427
|
}
|
|
2321
2428
|
registerLevelConfig(e) {
|
|
2322
2429
|
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 +2509,7 @@ var Le = class {
|
|
|
2402
2509
|
for (let e of this._loadedLevels.values()) await e.$dispose();
|
|
2403
2510
|
this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
|
|
2404
2511
|
}
|
|
2405
|
-
},
|
|
2512
|
+
}, Ue = class {
|
|
2406
2513
|
_audioEngine;
|
|
2407
2514
|
_channels = /* @__PURE__ */ new Map();
|
|
2408
2515
|
_masterMuted = !1;
|
|
@@ -2473,14 +2580,14 @@ var Le = class {
|
|
|
2473
2580
|
getChannels() {
|
|
2474
2581
|
return Array.from(this._channels.keys());
|
|
2475
2582
|
}
|
|
2476
|
-
},
|
|
2583
|
+
}, We = class {
|
|
2477
2584
|
_entityManager;
|
|
2478
2585
|
_levelManager;
|
|
2479
2586
|
_log;
|
|
2480
2587
|
_beforeSerializeHooks = [];
|
|
2481
2588
|
_afterDeserializeHooks = [];
|
|
2482
2589
|
constructor(e, t, n) {
|
|
2483
|
-
this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new
|
|
2590
|
+
this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new N("SaveManager"), this._log.info("SaveManager initialized");
|
|
2484
2591
|
}
|
|
2485
2592
|
onBeforeSerialize(e) {
|
|
2486
2593
|
this._beforeSerializeHooks.push(e);
|
|
@@ -2563,7 +2670,46 @@ var Le = class {
|
|
|
2563
2670
|
async $teardown() {
|
|
2564
2671
|
this._beforeSerializeHooks = [], this._afterDeserializeHooks = [], this._log.info("SaveManager torn down");
|
|
2565
2672
|
}
|
|
2566
|
-
},
|
|
2673
|
+
}, Ge = class {
|
|
2674
|
+
_viewer = null;
|
|
2675
|
+
_shown = /* @__PURE__ */ new Map();
|
|
2676
|
+
_materials = /* @__PURE__ */ new Map();
|
|
2677
|
+
showColliderForNode(e, t) {
|
|
2678
|
+
if (!e.physicsBody || this._shown.has(e)) return;
|
|
2679
|
+
let n = this._getViewer(e).showBody(e.physicsBody);
|
|
2680
|
+
if (!n) return;
|
|
2681
|
+
let r = { debugMesh: n };
|
|
2682
|
+
if (t) {
|
|
2683
|
+
let i = this._getColorMaterial(t, e);
|
|
2684
|
+
n.material = i, r.colorMaterial = i;
|
|
2685
|
+
}
|
|
2686
|
+
this._shown.set(e, r);
|
|
2687
|
+
}
|
|
2688
|
+
hideColliderForNode(e) {
|
|
2689
|
+
!this._shown.get(e) || !this._viewer || (e.physicsBody && this._viewer.hideBody(e.physicsBody), this._shown.delete(e));
|
|
2690
|
+
}
|
|
2691
|
+
hideAll() {
|
|
2692
|
+
for (let [e] of this._shown) this.hideColliderForNode(e);
|
|
2693
|
+
}
|
|
2694
|
+
isShown(e) {
|
|
2695
|
+
return this._shown.has(e);
|
|
2696
|
+
}
|
|
2697
|
+
async $teardown() {
|
|
2698
|
+
this.dispose();
|
|
2699
|
+
}
|
|
2700
|
+
dispose() {
|
|
2701
|
+
this._viewer &&= (this.hideAll(), this._viewer.dispose(), null), this._shown.clear();
|
|
2702
|
+
for (let e of this._materials.values()) e.dispose();
|
|
2703
|
+
this._materials.clear();
|
|
2704
|
+
}
|
|
2705
|
+
_getViewer(e) {
|
|
2706
|
+
return this._viewer ||= new pe(e.getScene()), this._viewer;
|
|
2707
|
+
}
|
|
2708
|
+
_getColorMaterial(e, t) {
|
|
2709
|
+
let n = this._materials.get(e);
|
|
2710
|
+
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);
|
|
2711
|
+
}
|
|
2712
|
+
}, Ke = class {
|
|
2567
2713
|
_keyboardDevice;
|
|
2568
2714
|
_keysState = {};
|
|
2569
2715
|
_onDeviceConnected;
|
|
@@ -2628,7 +2774,7 @@ var Le = class {
|
|
|
2628
2774
|
_notifyInputChanged(e) {
|
|
2629
2775
|
this._onInputChanged && this._onInputChanged(this._keyboardDevice, e);
|
|
2630
2776
|
}
|
|
2631
|
-
},
|
|
2777
|
+
}, qe = class {
|
|
2632
2778
|
_targetElement;
|
|
2633
2779
|
_mouseDevice;
|
|
2634
2780
|
_buttonState = {};
|
|
@@ -2747,7 +2893,7 @@ var Le = class {
|
|
|
2747
2893
|
_notifyInputChanged(e) {
|
|
2748
2894
|
this._onInputChanged && this._onInputChanged(this._mouseDevice, e);
|
|
2749
2895
|
}
|
|
2750
|
-
},
|
|
2896
|
+
}, Je = class {
|
|
2751
2897
|
_gamepadDevices = {};
|
|
2752
2898
|
_buttonStates = {};
|
|
2753
2899
|
_axesStates = {};
|
|
@@ -2881,14 +3027,14 @@ var Le = class {
|
|
|
2881
3027
|
_notifyInputChanged(e, t) {
|
|
2882
3028
|
this._onInputChanged && this._onInputChanged(e, t);
|
|
2883
3029
|
}
|
|
2884
|
-
},
|
|
3030
|
+
}, Ye = class {
|
|
2885
3031
|
_eventBus;
|
|
2886
3032
|
_keyboardRA;
|
|
2887
3033
|
_mouseRA;
|
|
2888
3034
|
_gamepadRA;
|
|
2889
3035
|
_log;
|
|
2890
3036
|
constructor(e, t, n) {
|
|
2891
|
-
this._eventBus = e, this._log = n?.getLogger("UserInputManager") || new
|
|
3037
|
+
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
3038
|
}
|
|
2893
3039
|
_publishDeviceConnected(e) {
|
|
2894
3040
|
this._log.debug(`Device connected: ${e.id} (${e.name})`), this._eventBus.publish({
|
|
@@ -2941,18 +3087,18 @@ var Le = class {
|
|
|
2941
3087
|
};
|
|
2942
3088
|
//#endregion
|
|
2943
3089
|
//#region src/utils/graphics.ts
|
|
2944
|
-
async function
|
|
2945
|
-
let n = new
|
|
3090
|
+
async function Xe(e, t) {
|
|
3091
|
+
let n = new le(e, t);
|
|
2946
3092
|
return await n.initAsync(), n;
|
|
2947
3093
|
}
|
|
2948
|
-
function
|
|
3094
|
+
function J(e, t) {
|
|
2949
3095
|
return new l(e, t.antialias, t.options, t.adaptToDeviceRatio);
|
|
2950
3096
|
}
|
|
2951
|
-
function
|
|
3097
|
+
function Ze(e) {
|
|
2952
3098
|
return new x(e);
|
|
2953
3099
|
}
|
|
2954
|
-
async function
|
|
2955
|
-
if (e === null) return console.debug("Using Null Engine"),
|
|
3100
|
+
async function Qe(e, t, n = !1) {
|
|
3101
|
+
if (e === null) return console.debug("Using Null Engine"), Ze(t);
|
|
2956
3102
|
if (n) if ("options" in t) {
|
|
2957
3103
|
let e = t;
|
|
2958
3104
|
t = {
|
|
@@ -2967,32 +3113,32 @@ async function Ye(e, t, n = !1) {
|
|
|
2967
3113
|
useLargeWorldRendering: !0
|
|
2968
3114
|
};
|
|
2969
3115
|
let r = t.engine || "auto";
|
|
2970
|
-
if (r === "webgpu") if (
|
|
2971
|
-
return console.debug("Using forced WebGPU engine"), await
|
|
3116
|
+
if (r === "webgpu") if (De()) try {
|
|
3117
|
+
return console.debug("Using forced WebGPU engine"), await Xe(e, t);
|
|
2972
3118
|
} catch (e) {
|
|
2973
3119
|
throw console.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
|
|
2974
3120
|
}
|
|
2975
3121
|
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"),
|
|
3122
|
+
if (r === "webgl") return console.debug("Using forced WebGL engine"), J(e, t);
|
|
3123
|
+
if (De()) try {
|
|
3124
|
+
return console.debug("Using WebGPU"), Xe(e, t).catch((n) => (console.warn("WebGPU initialization failed, falling back to WebGL:", n), J(e, t)));
|
|
2979
3125
|
} catch (e) {
|
|
2980
3126
|
console.warn("WebGPU initialization failed, falling back to WebGL:", e);
|
|
2981
3127
|
}
|
|
2982
3128
|
else console.warn("WebGPU not supported, falling back to WebGL.");
|
|
2983
|
-
return console.debug("Using WebGL"),
|
|
3129
|
+
return console.debug("Using WebGL"), J(e, t);
|
|
2984
3130
|
}
|
|
2985
3131
|
//#endregion
|
|
2986
3132
|
//#region src/utils/physics.ts
|
|
2987
|
-
async function
|
|
2988
|
-
return await
|
|
3133
|
+
async function $e() {
|
|
3134
|
+
return await me();
|
|
2989
3135
|
}
|
|
2990
|
-
function
|
|
3136
|
+
function et(e) {
|
|
2991
3137
|
return new p(!0, e);
|
|
2992
3138
|
}
|
|
2993
3139
|
//#endregion
|
|
2994
3140
|
//#region src/utils/raycast.ts
|
|
2995
|
-
var
|
|
3141
|
+
var tt = class {
|
|
2996
3142
|
_entityManager;
|
|
2997
3143
|
constructor(e) {
|
|
2998
3144
|
this._entityManager = e;
|
|
@@ -3058,7 +3204,7 @@ var Qe = class {
|
|
|
3058
3204
|
pickingInfo: e
|
|
3059
3205
|
};
|
|
3060
3206
|
}
|
|
3061
|
-
},
|
|
3207
|
+
}, nt = class {
|
|
3062
3208
|
_nextId = 0;
|
|
3063
3209
|
_delays = [];
|
|
3064
3210
|
_intervals = [];
|
|
@@ -3113,21 +3259,120 @@ var Qe = class {
|
|
|
3113
3259
|
for (let t of this._intervals) for (t.elapsed += e; t.elapsed >= t.periodMs;) t.callback(), t.elapsed -= t.periodMs;
|
|
3114
3260
|
for (let t of this._cooldowns) t.remaining > 0 && (t.remaining = Math.max(0, t.remaining - e));
|
|
3115
3261
|
}
|
|
3116
|
-
}
|
|
3262
|
+
};
|
|
3263
|
+
//#endregion
|
|
3264
|
+
//#region src/utils/entityProxy.ts
|
|
3265
|
+
function rt(e) {
|
|
3266
|
+
return new Proxy(e, { get(e, t) {
|
|
3267
|
+
if (typeof t == "symbol") return Reflect.get(e, t);
|
|
3268
|
+
if (t in e) {
|
|
3269
|
+
let n = Reflect.get(e, t);
|
|
3270
|
+
return typeof n == "function" ? n.bind(e) : n;
|
|
3271
|
+
}
|
|
3272
|
+
return e.getByName(t);
|
|
3273
|
+
} });
|
|
3274
|
+
}
|
|
3275
|
+
//#endregion
|
|
3276
|
+
//#region src/debug/builtins.ts
|
|
3277
|
+
function it(e, t) {
|
|
3278
|
+
return typeof e == "string" ? t.managers.entityManager.getByName(e) : e;
|
|
3279
|
+
}
|
|
3280
|
+
function at(e, t) {
|
|
3281
|
+
let n = t.managers.entityManager;
|
|
3282
|
+
if (e === void 0) return [...n.getAllEntities()];
|
|
3283
|
+
if (typeof e != "string") return [e];
|
|
3284
|
+
let r = n.getByName(e);
|
|
3285
|
+
if (r) return [r];
|
|
3286
|
+
let i = n.getByType(e);
|
|
3287
|
+
return i.length > 0 ? i : (console.warn(`[sage] No entity found with name or type "${e}"`), []);
|
|
3288
|
+
}
|
|
3289
|
+
function ot(e, t) {
|
|
3290
|
+
let n = t.managers.entityManager, r = t.managers.gameManager, i = t.managers.levelManager, a = [];
|
|
3291
|
+
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) => {
|
|
3292
|
+
let a = it(e, t);
|
|
3293
|
+
if (!a) {
|
|
3294
|
+
console.warn(`[sage] Entity not found: ${e}`);
|
|
3295
|
+
return;
|
|
3296
|
+
}
|
|
3297
|
+
if (!a.node) {
|
|
3298
|
+
console.warn(`[sage] Entity "${a.name ?? a.id}" has no node`);
|
|
3299
|
+
return;
|
|
3300
|
+
}
|
|
3301
|
+
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})`);
|
|
3302
|
+
}), e.expose("spawn", async (e, t, r, i) => {
|
|
3303
|
+
let a = await n.createEntity(e, { initialState: { position: {
|
|
3304
|
+
x: t,
|
|
3305
|
+
y: r,
|
|
3306
|
+
z: i
|
|
3307
|
+
} } });
|
|
3308
|
+
return console.log(`[sage] Spawned "${e}" (${a.id}) at (${t}, ${r}, ${i})`), a;
|
|
3309
|
+
}), e.expose("list", (e) => {
|
|
3310
|
+
let t;
|
|
3311
|
+
t = e ? n.getByType(e) : [...n.getAllEntities()];
|
|
3312
|
+
let r = t.map((e) => ({
|
|
3313
|
+
id: e.id,
|
|
3314
|
+
type: e.type,
|
|
3315
|
+
name: e.name ?? "(unnamed)",
|
|
3316
|
+
node: e.node?.name ?? "(no node)"
|
|
3317
|
+
}));
|
|
3318
|
+
return console.table(r), t;
|
|
3319
|
+
}), e.expose("inspect", (e) => {
|
|
3320
|
+
let n = it(e, t);
|
|
3321
|
+
if (!n) {
|
|
3322
|
+
console.warn(`[sage] Entity not found: ${e}`);
|
|
3323
|
+
return;
|
|
3324
|
+
}
|
|
3325
|
+
let r = {
|
|
3326
|
+
id: n.id,
|
|
3327
|
+
type: n.type,
|
|
3328
|
+
name: n.name,
|
|
3329
|
+
state: n.state,
|
|
3330
|
+
behaviors: n.behaviors.map((e) => e.name),
|
|
3331
|
+
node: n.node?.name ?? null,
|
|
3332
|
+
position: n.node?.position ?? null
|
|
3333
|
+
};
|
|
3334
|
+
return console.log("[sage] Entity info:", r), r;
|
|
3335
|
+
}), e.expose("showColliders", (e) => {
|
|
3336
|
+
let n = at(e, t);
|
|
3337
|
+
for (let e of n) e.showCollider();
|
|
3338
|
+
console.log(`[sage] Showing colliders for ${n.length} entity(s)`);
|
|
3339
|
+
}), e.expose("hideColliders", (e) => {
|
|
3340
|
+
let n = at(e, t);
|
|
3341
|
+
for (let e of n) e.hideCollider();
|
|
3342
|
+
console.log(`[sage] Hiding colliders for ${n.length} entity(s)`);
|
|
3343
|
+
}), e.expose("logEvents", (e) => {
|
|
3344
|
+
let n = e ?? "*", r = t.eventBus.subscribe(n, (e) => {
|
|
3345
|
+
console.log(`[sage] Event: ${e.type}`, e.payload);
|
|
3346
|
+
});
|
|
3347
|
+
return a.push(r), console.log(`[sage] Logging events matching "${n}"`), r;
|
|
3348
|
+
}), e.expose("stopLogging", () => {
|
|
3349
|
+
for (let e of a) e();
|
|
3350
|
+
console.log(`[sage] Stopped ${a.length} event logger(s)`), a.length = 0;
|
|
3351
|
+
}), e.expose("pause", () => {
|
|
3352
|
+
r.pause("debug console"), console.log("[sage] Game paused");
|
|
3353
|
+
}), e.expose("resume", () => {
|
|
3354
|
+
r.resume("debug console"), console.log("[sage] Game resumed");
|
|
3355
|
+
}), e.expose("slow", (e) => {
|
|
3356
|
+
t.renderEngine.timeStep = 1 / 60 / e, console.log(`[sage] Time scale set to ${e}x (timeStep=${1 / 60 / e})`);
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
//#endregion
|
|
3360
|
+
//#region src/interfaces/logger.ts
|
|
3361
|
+
var st = [
|
|
3117
3362
|
"trace",
|
|
3118
3363
|
"debug",
|
|
3119
3364
|
"info",
|
|
3120
3365
|
"warn",
|
|
3121
3366
|
"error",
|
|
3122
3367
|
"none"
|
|
3123
|
-
],
|
|
3368
|
+
], ct = class extends G {
|
|
3124
3369
|
name = "sound";
|
|
3125
3370
|
eventSubscriptions = [];
|
|
3126
3371
|
_sounds = /* @__PURE__ */ new Map();
|
|
3127
3372
|
_initialized = !1;
|
|
3128
3373
|
_audioManager = null;
|
|
3129
3374
|
_node = null;
|
|
3130
|
-
_log = new
|
|
3375
|
+
_log = new N("SoundBehavior");
|
|
3131
3376
|
onNodeAttached(e, t) {
|
|
3132
3377
|
if (this._initialized) return;
|
|
3133
3378
|
if (this._node = e, this._initialized = !0, this._log = t.logger.getLogger("SoundBehavior"), t.managers.audioManager) this._audioManager = t.managers.audioManager;
|
|
@@ -3189,7 +3434,7 @@ var Qe = class {
|
|
|
3189
3434
|
} else for (let t of this._sounds.values()) t.volume = e;
|
|
3190
3435
|
}
|
|
3191
3436
|
isPlaying(e) {
|
|
3192
|
-
return this._getSound(e)?.state ===
|
|
3437
|
+
return this._getSound(e)?.state === ae.Started;
|
|
3193
3438
|
}
|
|
3194
3439
|
getSoundNames() {
|
|
3195
3440
|
return Array.from(this._sounds.keys());
|
|
@@ -3210,7 +3455,7 @@ var Qe = class {
|
|
|
3210
3455
|
if (e) return this._sounds.get(e);
|
|
3211
3456
|
if (this._sounds.size === 1) return this._sounds.values().next().value;
|
|
3212
3457
|
}
|
|
3213
|
-
},
|
|
3458
|
+
}, Y = class {
|
|
3214
3459
|
_currentState;
|
|
3215
3460
|
transitions = /* @__PURE__ */ new Map();
|
|
3216
3461
|
wildcardTransitions = /* @__PURE__ */ new Map();
|
|
@@ -3265,13 +3510,13 @@ var Qe = class {
|
|
|
3265
3510
|
}
|
|
3266
3511
|
});
|
|
3267
3512
|
}
|
|
3268
|
-
},
|
|
3513
|
+
}, lt = class extends G {
|
|
3269
3514
|
name = "stateMachine";
|
|
3270
3515
|
eventSubscriptions = [];
|
|
3271
3516
|
stateMachine;
|
|
3272
3517
|
stateKey;
|
|
3273
3518
|
constructor() {
|
|
3274
|
-
super(), this.stateMachine = new
|
|
3519
|
+
super(), this.stateMachine = new Y(""), this.stateKey = "";
|
|
3275
3520
|
}
|
|
3276
3521
|
get currentState() {
|
|
3277
3522
|
return this.stateMachine.currentState;
|
|
@@ -3284,64 +3529,75 @@ var Qe = class {
|
|
|
3284
3529
|
}
|
|
3285
3530
|
static create(e) {
|
|
3286
3531
|
let { initialState: t, stateKey: n, transitions: r, wildcardTransitions: i } = e;
|
|
3287
|
-
class a extends
|
|
3532
|
+
class a extends lt {
|
|
3288
3533
|
constructor() {
|
|
3289
|
-
super(), this.stateKey = n, this.stateMachine = new
|
|
3534
|
+
super(), this.stateKey = n, this.stateMachine = new Y(t);
|
|
3290
3535
|
for (let e of r) this.stateMachine.addTransition(e.from, e.to, e.guard);
|
|
3291
3536
|
if (i) for (let e of i) this.stateMachine.addTransitionFromAny(e.to, e.guard);
|
|
3292
3537
|
}
|
|
3293
3538
|
}
|
|
3294
3539
|
return a;
|
|
3295
3540
|
}
|
|
3296
|
-
},
|
|
3297
|
-
function
|
|
3298
|
-
let r = e.
|
|
3299
|
-
|
|
3541
|
+
}, X = new N("ColliderHandler");
|
|
3542
|
+
function ut(e) {
|
|
3543
|
+
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();
|
|
3544
|
+
return i.rotateByQuaternionToRef(o, s), {
|
|
3545
|
+
extents: r,
|
|
3546
|
+
center: s
|
|
3547
|
+
};
|
|
3548
|
+
}
|
|
3549
|
+
function Z(e, t, n) {
|
|
3550
|
+
let r = e.getScene(), i = { mass: n };
|
|
3551
|
+
if (!(e instanceof y) && (t === w.BOX || t === w.SPHERE)) {
|
|
3552
|
+
let { extents: n, center: r } = ut(e);
|
|
3553
|
+
i.center = r, t === w.BOX ? i.extents = n : i.radius = Math.max(n.x, n.y, n.z) / 2;
|
|
3554
|
+
}
|
|
3555
|
+
new C(e, t, i, r);
|
|
3300
3556
|
}
|
|
3301
|
-
function
|
|
3557
|
+
function dt(e, t) {
|
|
3302
3558
|
let n = e.getChildMeshes().find((e) => e.metadata?.collider_mesh === !0);
|
|
3303
|
-
n instanceof y ? (n.isVisible = !1,
|
|
3559
|
+
n instanceof y ? (n.isVisible = !1, Z(n, w.MESH, t)) : Z(e, w.MESH, t);
|
|
3304
3560
|
}
|
|
3305
|
-
function
|
|
3561
|
+
function ft(t) {
|
|
3306
3562
|
t.registerPropertyHandler("collider", (t, n, r, i) => {
|
|
3307
3563
|
let a = n;
|
|
3308
|
-
if (
|
|
3564
|
+
if (X.debug(`Processing collider: ${t.name} -> ${a} (isMesh: ${t instanceof y})`), !r.scene) throw Error("Scene not available for collider handler");
|
|
3309
3565
|
if (!(t instanceof y) && a === "mesh") {
|
|
3310
|
-
|
|
3566
|
+
X.warn(`Skipping mesh collider for ${t.name}: not a Mesh instance`);
|
|
3311
3567
|
return;
|
|
3312
3568
|
}
|
|
3313
3569
|
let o = t.metadata?.collider_mass ?? 0;
|
|
3314
3570
|
switch (a) {
|
|
3315
3571
|
case "box":
|
|
3316
|
-
|
|
3572
|
+
Z(t, w.BOX, o);
|
|
3317
3573
|
break;
|
|
3318
3574
|
case "sphere":
|
|
3319
|
-
|
|
3575
|
+
Z(t, w.SPHERE, o);
|
|
3320
3576
|
break;
|
|
3321
3577
|
case "mesh":
|
|
3322
|
-
|
|
3578
|
+
dt(t, o);
|
|
3323
3579
|
break;
|
|
3324
3580
|
case "none":
|
|
3325
3581
|
t instanceof e && (t.checkCollisions = !1);
|
|
3326
3582
|
break;
|
|
3327
|
-
default:
|
|
3583
|
+
default: X.warn(`Unknown collider type: ${a}`);
|
|
3328
3584
|
}
|
|
3329
3585
|
t.metadata?.collider_kinematic && t instanceof e && t.physicsBody && (t.physicsBody.disablePreStep = !1);
|
|
3330
3586
|
});
|
|
3331
3587
|
}
|
|
3332
3588
|
//#endregion
|
|
3333
3589
|
//#region src/handlers/lod.ts
|
|
3334
|
-
var
|
|
3335
|
-
function
|
|
3590
|
+
var pt = new N("LodHandler");
|
|
3591
|
+
function mt(e) {
|
|
3336
3592
|
return e.split(",").map((e) => parseFloat(e.trim())).filter((e) => !isNaN(e));
|
|
3337
3593
|
}
|
|
3338
|
-
function
|
|
3594
|
+
function ht(e) {
|
|
3339
3595
|
e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
|
|
3340
3596
|
let i = t;
|
|
3341
3597
|
if (!(e instanceof y)) return;
|
|
3342
|
-
let a =
|
|
3598
|
+
let a = mt(i);
|
|
3343
3599
|
if (a.length === 0) {
|
|
3344
|
-
|
|
3600
|
+
pt.warn(`Invalid lod_distances value: ${i}`);
|
|
3345
3601
|
return;
|
|
3346
3602
|
}
|
|
3347
3603
|
let o = e.getChildMeshes(!0), s = Math.min(a.length, o.length);
|
|
@@ -3352,14 +3608,14 @@ function st(e) {
|
|
|
3352
3608
|
}
|
|
3353
3609
|
//#endregion
|
|
3354
3610
|
//#region src/handlers/occluder.ts
|
|
3355
|
-
function
|
|
3611
|
+
function gt(e) {
|
|
3356
3612
|
e.registerPropertyHandler("occluder", (e, t, n, r) => {
|
|
3357
3613
|
t && e instanceof y && (e.isOccluder = !0, e.isVisible = !1);
|
|
3358
3614
|
});
|
|
3359
3615
|
}
|
|
3360
3616
|
//#endregion
|
|
3361
3617
|
//#region src/utils/metadata.ts
|
|
3362
|
-
function
|
|
3618
|
+
function _t(e, t) {
|
|
3363
3619
|
let n = {}, r = `${t}_`;
|
|
3364
3620
|
for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
|
|
3365
3621
|
let e = t.slice(r.length);
|
|
@@ -3369,14 +3625,14 @@ function ct(e, t) {
|
|
|
3369
3625
|
}
|
|
3370
3626
|
//#endregion
|
|
3371
3627
|
//#region src/handlers/sound.ts
|
|
3372
|
-
var
|
|
3373
|
-
function
|
|
3628
|
+
var vt = new N("SoundHandler");
|
|
3629
|
+
function yt(e) {
|
|
3374
3630
|
e.registerPropertyHandler("sound", (e, t, n, r) => {
|
|
3375
3631
|
let i = t;
|
|
3376
3632
|
if (!n.scene) throw Error("Scene not available for sound handler");
|
|
3377
|
-
let a =
|
|
3633
|
+
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
3634
|
if (!f) {
|
|
3379
|
-
|
|
3635
|
+
vt.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
|
|
3380
3636
|
return;
|
|
3381
3637
|
}
|
|
3382
3638
|
f.createSound(`${e.name}_sound`, i, d, {
|
|
@@ -3389,13 +3645,13 @@ function ut(e) {
|
|
|
3389
3645
|
}).then((t) => {
|
|
3390
3646
|
c && t.spatial.attach(e);
|
|
3391
3647
|
}).catch((t) => {
|
|
3392
|
-
|
|
3648
|
+
vt.error(`Failed to create sound for node "${e.name}": ${t}`);
|
|
3393
3649
|
});
|
|
3394
3650
|
});
|
|
3395
3651
|
}
|
|
3396
3652
|
//#endregion
|
|
3397
3653
|
//#region src/handlers/trigger.ts
|
|
3398
|
-
function
|
|
3654
|
+
function Q(e, n, r, i, a) {
|
|
3399
3655
|
let o = a === "enter" ? t.OnIntersectionEnterTrigger : t.OnIntersectionExitTrigger, s = `trigger:${a}`;
|
|
3400
3656
|
e.registerAction(new u({
|
|
3401
3657
|
trigger: o,
|
|
@@ -3410,10 +3666,10 @@ function dt(e, n, r, i, a) {
|
|
|
3410
3666
|
});
|
|
3411
3667
|
}));
|
|
3412
3668
|
}
|
|
3413
|
-
function
|
|
3414
|
-
|
|
3669
|
+
function bt(e, t, n, r) {
|
|
3670
|
+
Q(e, t, n, r, "enter"), Q(e, t, n, r, "exit");
|
|
3415
3671
|
}
|
|
3416
|
-
function
|
|
3672
|
+
function xt(n) {
|
|
3417
3673
|
n.registerPropertyHandler("trigger", (n, r, i, a) => {
|
|
3418
3674
|
let o = r, s = i.scene;
|
|
3419
3675
|
if (!s) throw Error("Scene not available for trigger handler");
|
|
@@ -3422,9 +3678,9 @@ function pt(n) {
|
|
|
3422
3678
|
n.isVisible = !1, n.checkCollisions = !0;
|
|
3423
3679
|
let l = n.actionManager ?? new t(s);
|
|
3424
3680
|
n.actionManager = l;
|
|
3425
|
-
for (let e of s.meshes) e !== n && !e.metadata?.trigger &&
|
|
3681
|
+
for (let e of s.meshes) e !== n && !e.metadata?.trigger && bt(l, o, c, e);
|
|
3426
3682
|
let u = s.onNewMeshAddedObservable.add((e) => {
|
|
3427
|
-
e !== n && !e.metadata?.trigger &&
|
|
3683
|
+
e !== n && !e.metadata?.trigger && bt(l, o, c, e);
|
|
3428
3684
|
});
|
|
3429
3685
|
n.onDisposeObservable.add(() => {
|
|
3430
3686
|
s.onNewMeshAddedObservable.remove(u);
|
|
@@ -3433,7 +3689,7 @@ function pt(n) {
|
|
|
3433
3689
|
}
|
|
3434
3690
|
//#endregion
|
|
3435
3691
|
//#region src/handlers/visible.ts
|
|
3436
|
-
function
|
|
3692
|
+
function $(t) {
|
|
3437
3693
|
t.registerPropertyHandler("visible", (t, n, r, i) => {
|
|
3438
3694
|
if (!(t instanceof e)) return;
|
|
3439
3695
|
let a = !0;
|
|
@@ -3442,39 +3698,41 @@ function mt(t) {
|
|
|
3442
3698
|
}
|
|
3443
3699
|
//#endregion
|
|
3444
3700
|
//#region src/handlers/index.ts
|
|
3445
|
-
function
|
|
3446
|
-
|
|
3701
|
+
function St(e) {
|
|
3702
|
+
ft(e), ht(e), gt(e), yt(e), xt(e), $(e);
|
|
3447
3703
|
}
|
|
3448
3704
|
//#endregion
|
|
3449
3705
|
//#region src/sage.ts
|
|
3450
|
-
async function
|
|
3451
|
-
let r = new
|
|
3452
|
-
i.info(`Initializing SAGE Game Engine v${
|
|
3453
|
-
let a = await
|
|
3706
|
+
async function Ct(e, t, n = {}) {
|
|
3707
|
+
let r = new P(n.logLevel || "debug"), i = r.getLogger("SAGE");
|
|
3708
|
+
i.info(`Initializing SAGE Game Engine v${k}...`), i.debug("Creating rendering engine...");
|
|
3709
|
+
let a = await Qe(e, {
|
|
3454
3710
|
antialias: !0,
|
|
3455
3711
|
adaptToDeviceRatio: !0,
|
|
3456
3712
|
...n.renderOptions
|
|
3457
3713
|
}, n.largeWorldRendering ?? !1);
|
|
3458
3714
|
i.debug("Creating physics engine...");
|
|
3459
|
-
let o = await
|
|
3715
|
+
let o = await $e(), s = et(o);
|
|
3460
3716
|
i.debug("Creating event bus...");
|
|
3461
|
-
let c = new
|
|
3717
|
+
let c = new F(r);
|
|
3462
3718
|
i.debug("Creating scene engine...");
|
|
3463
|
-
let l = new
|
|
3719
|
+
let l = new L(e, a, o, r);
|
|
3464
3720
|
i.debug("Creating managers...");
|
|
3465
|
-
let u = new
|
|
3721
|
+
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;
|
|
3722
|
+
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...");
|
|
3723
|
+
let v = new Ge();
|
|
3466
3724
|
i.debug("Creating raycast helper...");
|
|
3467
|
-
let
|
|
3725
|
+
let y = new tt(p);
|
|
3468
3726
|
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..."),
|
|
3727
|
+
let b = new nt();
|
|
3728
|
+
g.registerFrameCallback((e) => b.tick(e * 1e3));
|
|
3729
|
+
let x, S;
|
|
3730
|
+
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
3731
|
for (let e of t) p.registerEntityDefinition(e);
|
|
3474
3732
|
if (i.debug("Registering default input bindings..."), n.bindings) for (let e of n.bindings) f.registerBinding(e);
|
|
3475
|
-
let
|
|
3733
|
+
let C = new A(e, a, s, c, r, y, b, {
|
|
3476
3734
|
sceneEngine: l,
|
|
3477
|
-
audioEngine:
|
|
3735
|
+
audioEngine: x
|
|
3478
3736
|
}, {
|
|
3479
3737
|
assetManager: u,
|
|
3480
3738
|
bindingManager: f,
|
|
@@ -3483,11 +3741,17 @@ async function gt(e, t, n = {}) {
|
|
|
3483
3741
|
inputManager: d,
|
|
3484
3742
|
levelManager: m,
|
|
3485
3743
|
saveManager: h,
|
|
3486
|
-
audioManager:
|
|
3487
|
-
}, n.largeWorldRendering ?? !1
|
|
3488
|
-
|
|
3744
|
+
audioManager: S
|
|
3745
|
+
}, n.largeWorldRendering ?? !1, {
|
|
3746
|
+
colliders: v,
|
|
3747
|
+
console: _,
|
|
3748
|
+
expose: (e, t) => {
|
|
3749
|
+
_?.expose(e, t);
|
|
3750
|
+
}
|
|
3751
|
+
});
|
|
3752
|
+
return p.$setGameEngine(C), m.$setGameEngine(C), _ && ot(_, C), C;
|
|
3489
3753
|
}
|
|
3490
3754
|
//#endregion
|
|
3491
|
-
export {
|
|
3755
|
+
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
3756
|
|
|
3493
3757
|
//# sourceMappingURL=sage.es.js.map
|