@skewedaspect/sage 0.9.1 → 0.9.2
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/gameLevel.d.ts +3 -1
- package/dist/sage.d.ts +1 -1
- package/dist/sage.es.js +215 -198
- 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/vectors.d.ts +18 -1
- package/package.json +1 -1
package/dist/sage.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 _,
|
|
2
|
-
import { registerBuiltInLoaders as
|
|
3
|
-
import { GeospatialCamera as
|
|
4
|
-
import { ClusteredLightContainer as
|
|
5
|
-
import
|
|
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 ee, PhysicsAggregate as S, PhysicsShapeType as C, PointLight as te, Quaternion as w, RectAreaLight as T, SSAO2RenderingPipeline as ne, Scene as re, SelectionOutlineLayer as ie, SoundState as E, SpotLight as D, StandardMaterial as O, Texture as ae, TransformNode as k, UniversalCamera as oe, Vector3 as A, WebGPUEngine as se } from "@babylonjs/core";
|
|
2
|
+
import { registerBuiltInLoaders as ce } from "@babylonjs/loaders/dynamic";
|
|
3
|
+
import { GeospatialCamera as le } from "@babylonjs/core/Cameras/geospatialCamera";
|
|
4
|
+
import { ClusteredLightContainer as ue } from "@babylonjs/core/Lights/Clustered/clusteredLightContainer";
|
|
5
|
+
import de from "@babylonjs/havok";
|
|
6
6
|
//#region src/utils/version.ts
|
|
7
|
-
var
|
|
7
|
+
var j = "0.9.2", fe = class {
|
|
8
8
|
canvas;
|
|
9
9
|
renderEngine;
|
|
10
10
|
physics;
|
|
@@ -42,11 +42,11 @@ var O = "0.9.1", k = class {
|
|
|
42
42
|
return this.eventBus.subscribe(`action:${e}`, t);
|
|
43
43
|
}
|
|
44
44
|
async start() {
|
|
45
|
-
this.started ? this._log.warn("Game engine is already started. Skipping start.") : (this._log.info(`Starting SkewedAspect Game Engine (Version: ${
|
|
45
|
+
this.started ? this._log.warn("Game engine is already started. Skipping start.") : (this._log.info(`Starting SkewedAspect Game Engine (Version: ${j})...`), 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
46
|
}
|
|
47
47
|
async stop() {
|
|
48
48
|
if (this.started) {
|
|
49
|
-
this._log.info(`Stopping SkewedAspect Game Engine (Version: ${
|
|
49
|
+
this._log.info(`Stopping SkewedAspect Game Engine (Version: ${j})...`);
|
|
50
50
|
let e = null;
|
|
51
51
|
if (this._onTeardownHook) try {
|
|
52
52
|
this._log.debug("Executing onTeardown hook..."), await this._onTeardownHook(this);
|
|
@@ -72,7 +72,7 @@ var O = "0.9.1", k = class {
|
|
|
72
72
|
if (this.started = !1, this._log.info("Game engine stopped successfully"), e) throw e;
|
|
73
73
|
} else this._log.warn("Game engine is not started. Skipping stop.");
|
|
74
74
|
}
|
|
75
|
-
},
|
|
75
|
+
}, pe = class {
|
|
76
76
|
timers;
|
|
77
77
|
constructor() {
|
|
78
78
|
this.timers = /* @__PURE__ */ new Map();
|
|
@@ -131,7 +131,7 @@ var O = "0.9.1", k = class {
|
|
|
131
131
|
console.info(`${a} Timer '${t}' completed in ${i.toFixed(2)}ms`, o, s, c);
|
|
132
132
|
} else console.warn(`[${e}]: Timer '${t}' does not exist`);
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, me = class {
|
|
135
135
|
trace(e, t, ...n) {}
|
|
136
136
|
debug(e, t, ...n) {}
|
|
137
137
|
info(e, t, ...n) {}
|
|
@@ -143,7 +143,7 @@ var O = "0.9.1", k = class {
|
|
|
143
143
|
category;
|
|
144
144
|
backend;
|
|
145
145
|
minLevel;
|
|
146
|
-
constructor(e, t = "none", n = new
|
|
146
|
+
constructor(e, t = "none", n = new me()) {
|
|
147
147
|
this.category = e, this.backend = n, this.minLevel = t;
|
|
148
148
|
}
|
|
149
149
|
updateSettings(e, t) {
|
|
@@ -181,11 +181,11 @@ var O = "0.9.1", k = class {
|
|
|
181
181
|
default: return !1;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
},
|
|
184
|
+
}, he = class {
|
|
185
185
|
backend;
|
|
186
186
|
level;
|
|
187
187
|
loggers;
|
|
188
|
-
constructor(e = "debug", t = new
|
|
188
|
+
constructor(e = "debug", t = new pe()) {
|
|
189
189
|
this.backend = t, this.level = e, this.loggers = /* @__PURE__ */ new Map();
|
|
190
190
|
}
|
|
191
191
|
setBackend(e) {
|
|
@@ -205,7 +205,7 @@ var O = "0.9.1", k = class {
|
|
|
205
205
|
let t = this.loggers.get(e);
|
|
206
206
|
return t || (t = new M(e, this.level, this.backend), this.loggers.set(e, t)), t;
|
|
207
207
|
}
|
|
208
|
-
},
|
|
208
|
+
}, ge = class {
|
|
209
209
|
directMap = /* @__PURE__ */ new Map();
|
|
210
210
|
patternSubs = /* @__PURE__ */ new Set();
|
|
211
211
|
_log;
|
|
@@ -255,7 +255,7 @@ var O = "0.9.1", k = class {
|
|
|
255
255
|
async $teardown() {
|
|
256
256
|
this._log.debug("Tearing down EventBus"), this.directMap.clear(), this.patternSubs.clear();
|
|
257
257
|
}
|
|
258
|
-
},
|
|
258
|
+
}, N = class {
|
|
259
259
|
_engine = null;
|
|
260
260
|
_mainBus = null;
|
|
261
261
|
_buses = /* @__PURE__ */ new Map();
|
|
@@ -299,8 +299,8 @@ var O = "0.9.1", k = class {
|
|
|
299
299
|
};
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/engines/scene.ts
|
|
302
|
-
|
|
303
|
-
var
|
|
302
|
+
ce();
|
|
303
|
+
var P = class {
|
|
304
304
|
_canvas;
|
|
305
305
|
_engine;
|
|
306
306
|
_havok;
|
|
@@ -311,14 +311,14 @@ var I = class {
|
|
|
311
311
|
createScene() {
|
|
312
312
|
return new re(this._engine);
|
|
313
313
|
}
|
|
314
|
-
enablePhysics(e, t = new
|
|
314
|
+
enablePhysics(e, t = new A(0, -9.8, 0), n) {
|
|
315
315
|
this._log.debug(`Enabling physics with gravity (${t.x}, ${t.y}, ${t.z})...`);
|
|
316
316
|
let r = n === void 0 ? void 0 : { floatingOriginWorldRadius: n }, i = new p(!0, this._havok, r);
|
|
317
317
|
e.enablePhysics(t, i);
|
|
318
318
|
}
|
|
319
319
|
createFreeCamera(e, t, n, r) {
|
|
320
320
|
let i = new d(e, t, n);
|
|
321
|
-
return i.setTarget(
|
|
321
|
+
return i.setTarget(A.Zero()), r ??= this._canvas, r && i.attachControl(r, !0), i;
|
|
322
322
|
}
|
|
323
323
|
createHemisphericLight(e, t, n, r = .7) {
|
|
324
324
|
let i = new m(e, t, n);
|
|
@@ -329,32 +329,32 @@ var I = class {
|
|
|
329
329
|
return i.intensity = r, i;
|
|
330
330
|
}
|
|
331
331
|
createPointLight(e, t, n, r = 1) {
|
|
332
|
-
let i = new
|
|
332
|
+
let i = new te(e, t, n);
|
|
333
333
|
return i.intensity = r, i;
|
|
334
334
|
}
|
|
335
335
|
createSpotLight(e, t, n, r, i, a, o = 1) {
|
|
336
|
-
let s = new
|
|
336
|
+
let s = new D(e, t, n, r, i, a);
|
|
337
337
|
return s.intensity = o, s;
|
|
338
338
|
}
|
|
339
339
|
createRectAreaLight(e, t, n, r, i, a = 1) {
|
|
340
|
-
let o = new
|
|
340
|
+
let o = new T(e, t, n, r, i);
|
|
341
341
|
return o.intensity = a, o;
|
|
342
342
|
}
|
|
343
343
|
createSphere(e, t = {}, n) {
|
|
344
|
-
return
|
|
344
|
+
return b.CreateSphere(e, {
|
|
345
345
|
diameter: 1,
|
|
346
346
|
segments: 32,
|
|
347
347
|
...t
|
|
348
348
|
}, n);
|
|
349
349
|
}
|
|
350
350
|
createBox(e, t = {}, n) {
|
|
351
|
-
return
|
|
351
|
+
return b.CreateBox(e, {
|
|
352
352
|
size: 1,
|
|
353
353
|
...t
|
|
354
354
|
}, n);
|
|
355
355
|
}
|
|
356
356
|
createGround(e, t = {}, n) {
|
|
357
|
-
return
|
|
357
|
+
return b.CreateGround(e, {
|
|
358
358
|
width: 6,
|
|
359
359
|
height: 6,
|
|
360
360
|
subdivisions: 2,
|
|
@@ -362,7 +362,7 @@ var I = class {
|
|
|
362
362
|
}, n);
|
|
363
363
|
}
|
|
364
364
|
createCylinder(e, t = {}, n) {
|
|
365
|
-
return
|
|
365
|
+
return b.CreateCylinder(e, {
|
|
366
366
|
height: 2,
|
|
367
367
|
diameterTop: 1,
|
|
368
368
|
diameterBottom: 1,
|
|
@@ -370,7 +370,7 @@ var I = class {
|
|
|
370
370
|
}, n);
|
|
371
371
|
}
|
|
372
372
|
addPhysics(e, t, n = {}, r) {
|
|
373
|
-
return new
|
|
373
|
+
return new S(e, t, {
|
|
374
374
|
mass: 1,
|
|
375
375
|
restitution: .75,
|
|
376
376
|
friction: .5,
|
|
@@ -398,7 +398,7 @@ var I = class {
|
|
|
398
398
|
async $teardown() {
|
|
399
399
|
this._log.info("Tearing down SceneEngine"), this._log.info("SceneEngine torn down successfully");
|
|
400
400
|
}
|
|
401
|
-
},
|
|
401
|
+
}, F = class {
|
|
402
402
|
_eventBus;
|
|
403
403
|
_sceneEngine;
|
|
404
404
|
_log;
|
|
@@ -491,27 +491,27 @@ var I = class {
|
|
|
491
491
|
async $teardown() {
|
|
492
492
|
this.disposeAll();
|
|
493
493
|
}
|
|
494
|
-
},
|
|
494
|
+
}, I = [
|
|
495
495
|
"trigger",
|
|
496
496
|
"toggle",
|
|
497
497
|
"value"
|
|
498
|
-
],
|
|
498
|
+
], _e = [
|
|
499
499
|
"keyboard",
|
|
500
500
|
"mouse",
|
|
501
501
|
"gamepad"
|
|
502
502
|
];
|
|
503
|
-
function
|
|
503
|
+
function L(e) {
|
|
504
504
|
return e.type === "keyboard";
|
|
505
505
|
}
|
|
506
|
-
function
|
|
506
|
+
function R(e) {
|
|
507
507
|
return e.type === "mouse";
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function z(e) {
|
|
510
510
|
return e.type === "gamepad";
|
|
511
511
|
}
|
|
512
512
|
//#endregion
|
|
513
513
|
//#region src/classes/bindings/trigger.ts
|
|
514
|
-
var
|
|
514
|
+
var ve = class {
|
|
515
515
|
type = "trigger";
|
|
516
516
|
action;
|
|
517
517
|
context;
|
|
@@ -582,7 +582,7 @@ var he = class {
|
|
|
582
582
|
options: this.options
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
|
-
},
|
|
585
|
+
}, ye = class {
|
|
586
586
|
type = "toggle";
|
|
587
587
|
action;
|
|
588
588
|
context;
|
|
@@ -656,7 +656,7 @@ var he = class {
|
|
|
656
656
|
options: this.options
|
|
657
657
|
};
|
|
658
658
|
}
|
|
659
|
-
},
|
|
659
|
+
}, be = class {
|
|
660
660
|
type = "value";
|
|
661
661
|
action;
|
|
662
662
|
context;
|
|
@@ -719,7 +719,7 @@ var he = class {
|
|
|
719
719
|
options: this.options
|
|
720
720
|
};
|
|
721
721
|
}
|
|
722
|
-
},
|
|
722
|
+
}, xe = class e {
|
|
723
723
|
sourceType = "key";
|
|
724
724
|
sourceKey;
|
|
725
725
|
useDelta;
|
|
@@ -742,7 +742,7 @@ var he = class {
|
|
|
742
742
|
options: { useDelta: this.useDelta }
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
|
-
},
|
|
745
|
+
}, Se = class e {
|
|
746
746
|
sourceType;
|
|
747
747
|
sourceKey;
|
|
748
748
|
constructor(e, t) {
|
|
@@ -777,7 +777,7 @@ var he = class {
|
|
|
777
777
|
sourceKey: this.sourceKey
|
|
778
778
|
};
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, Ce = class e {
|
|
781
781
|
sourceType;
|
|
782
782
|
sourceKey;
|
|
783
783
|
useAnalogValue;
|
|
@@ -816,7 +816,7 @@ var he = class {
|
|
|
816
816
|
}
|
|
817
817
|
};
|
|
818
818
|
}
|
|
819
|
-
},
|
|
819
|
+
}, we = .05, Te = .5, Ee = class {
|
|
820
820
|
_bindings = /* @__PURE__ */ new Map();
|
|
821
821
|
_actions = /* @__PURE__ */ new Map();
|
|
822
822
|
_contexts = /* @__PURE__ */ new Map();
|
|
@@ -849,22 +849,22 @@ var he = class {
|
|
|
849
849
|
return t;
|
|
850
850
|
}
|
|
851
851
|
_shouldUpdateActiveDevice(e) {
|
|
852
|
-
return
|
|
852
|
+
return R(e) ? Object.values(e.buttons).some((e) => e.pressed) || e.wheel !== void 0 : z(e) ? Object.values(e.buttons).some((e) => e.pressed) || Object.values(e.axes).some((e) => Math.abs(e) > we) : !0;
|
|
853
853
|
}
|
|
854
854
|
_createBindingFromDefinition(e) {
|
|
855
855
|
let t = this._actions.get(e.action);
|
|
856
856
|
if (!t) return this._log.warn(`Cannot create binding: Action "${e.action}" not found.`), null;
|
|
857
857
|
let { deviceID: n, ...r } = e.input;
|
|
858
858
|
switch (e.type) {
|
|
859
|
-
case "trigger": return new
|
|
859
|
+
case "trigger": return new ve(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
|
|
860
860
|
...e.options || {},
|
|
861
861
|
context: e.context
|
|
862
862
|
});
|
|
863
|
-
case "toggle": return new
|
|
863
|
+
case "toggle": return new ye(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
|
|
864
864
|
...e.options || {},
|
|
865
865
|
context: e.context
|
|
866
866
|
});
|
|
867
|
-
case "value": return new
|
|
867
|
+
case "value": return new be(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
|
|
868
868
|
...e.options || {},
|
|
869
869
|
context: e.context
|
|
870
870
|
});
|
|
@@ -873,16 +873,16 @@ var he = class {
|
|
|
873
873
|
}
|
|
874
874
|
_createInputSourceFromDefinition(e) {
|
|
875
875
|
switch (e.type) {
|
|
876
|
-
case "keyboard": return new
|
|
876
|
+
case "keyboard": return new xe(e.sourceKey, e.options);
|
|
877
877
|
case "mouse": {
|
|
878
878
|
let t = e.sourceType;
|
|
879
879
|
if (!(t === "button" || t === "position" || t === "wheel")) throw Error(`Invalid mouse source type: ${t}`);
|
|
880
|
-
return new
|
|
880
|
+
return new Se(t, e.sourceKey);
|
|
881
881
|
}
|
|
882
882
|
case "gamepad": {
|
|
883
883
|
let t = e.sourceType;
|
|
884
884
|
if (!(t === "button" || t === "axis")) throw Error(`Invalid gamepad source type: ${t}`);
|
|
885
|
-
return new
|
|
885
|
+
return new Ce(t, e.sourceKey, e.options);
|
|
886
886
|
}
|
|
887
887
|
default: throw Error(`Unsupported input source type: ${e.type}`);
|
|
888
888
|
}
|
|
@@ -893,7 +893,7 @@ var he = class {
|
|
|
893
893
|
let { options: r } = n;
|
|
894
894
|
if (!r.deviceTypes.includes(e.type)) return;
|
|
895
895
|
let i = null;
|
|
896
|
-
if (
|
|
896
|
+
if (L(t)) {
|
|
897
897
|
if (t.event?.repeat === !0) return;
|
|
898
898
|
for (let n of Object.keys(t.delta)) if (t.delta[n] === !0) {
|
|
899
899
|
i = {
|
|
@@ -904,7 +904,7 @@ var he = class {
|
|
|
904
904
|
};
|
|
905
905
|
break;
|
|
906
906
|
}
|
|
907
|
-
} else if (
|
|
907
|
+
} else if (R(t)) {
|
|
908
908
|
for (let n of Object.keys(t.buttons)) if (t.buttons[n].pressed) {
|
|
909
909
|
i = {
|
|
910
910
|
type: "mouse",
|
|
@@ -914,7 +914,7 @@ var he = class {
|
|
|
914
914
|
};
|
|
915
915
|
break;
|
|
916
916
|
}
|
|
917
|
-
} else if (
|
|
917
|
+
} else if (z(t)) {
|
|
918
918
|
for (let n of Object.keys(t.buttons)) if (t.buttons[n].pressed) {
|
|
919
919
|
i = {
|
|
920
920
|
type: "gamepad",
|
|
@@ -925,7 +925,7 @@ var he = class {
|
|
|
925
925
|
break;
|
|
926
926
|
}
|
|
927
927
|
if (!i) {
|
|
928
|
-
for (let n of Object.keys(t.axes)) if (Math.abs(t.axes[n]) >
|
|
928
|
+
for (let n of Object.keys(t.axes)) if (Math.abs(t.axes[n]) > Te) {
|
|
929
929
|
i = {
|
|
930
930
|
type: "gamepad",
|
|
931
931
|
sourceType: "axis",
|
|
@@ -1040,7 +1040,7 @@ var he = class {
|
|
|
1040
1040
|
return this._contexts.get(e) || null;
|
|
1041
1041
|
}
|
|
1042
1042
|
$registerBinding(e) {
|
|
1043
|
-
if (!
|
|
1043
|
+
if (!I.includes(e.type)) throw Error(`Invalid binding type: ${e.type}`);
|
|
1044
1044
|
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
1045
|
}
|
|
1046
1046
|
registerBinding(e) {
|
|
@@ -1110,15 +1110,15 @@ var he = class {
|
|
|
1110
1110
|
};
|
|
1111
1111
|
//#endregion
|
|
1112
1112
|
//#region src/utils/capabilities.ts
|
|
1113
|
-
function
|
|
1113
|
+
function B() {
|
|
1114
1114
|
return typeof window < "u" && window.document !== void 0;
|
|
1115
1115
|
}
|
|
1116
|
-
function
|
|
1117
|
-
return
|
|
1116
|
+
function V() {
|
|
1117
|
+
return B() && !!window.navigator.gpu;
|
|
1118
1118
|
}
|
|
1119
1119
|
//#endregion
|
|
1120
1120
|
//#region node_modules/hexoid/dist/index.mjs
|
|
1121
|
-
for (var
|
|
1121
|
+
for (var De = class {
|
|
1122
1122
|
_engine;
|
|
1123
1123
|
_eventBus;
|
|
1124
1124
|
_entityManager;
|
|
@@ -1132,7 +1132,7 @@ for (var we = class {
|
|
|
1132
1132
|
_paused = !1;
|
|
1133
1133
|
started = !1;
|
|
1134
1134
|
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 M("GameManager"), this._boundRenderLoop = this._renderLoop.bind(this), this._boundResizeHandler = this._resizeHandler.bind(this),
|
|
1135
|
+
this._engine = e, this._eventBus = t, this._entityManager = n, this._inputManager = r, this._levelManager = i, this._log = a?.getLogger("GameManager") || new M("GameManager"), this._boundRenderLoop = this._renderLoop.bind(this), this._boundResizeHandler = this._resizeHandler.bind(this), B() && window.addEventListener("resize", this._boundResizeHandler);
|
|
1136
1136
|
}
|
|
1137
1137
|
get currentScene() {
|
|
1138
1138
|
return this._levelManager.currentLevel?.scene ?? null;
|
|
@@ -1192,23 +1192,23 @@ for (var we = class {
|
|
|
1192
1192
|
});
|
|
1193
1193
|
}
|
|
1194
1194
|
async $teardown() {
|
|
1195
|
-
this._log.info("Tearing down GameManager"), this.started && await this.stop(),
|
|
1195
|
+
this._log.info("Tearing down GameManager"), this.started && await this.stop(), B() && window.removeEventListener("resize", this._boundResizeHandler), this._frameCallbacks = [], this._log.info("GameManager torn down successfully");
|
|
1196
1196
|
}
|
|
1197
|
-
},
|
|
1198
|
-
function
|
|
1197
|
+
}, H = 256, U = []; H--;) U[H] = (H + 256).toString(16).substring(1);
|
|
1198
|
+
function Oe(e) {
|
|
1199
1199
|
e ||= 16;
|
|
1200
1200
|
var t = "", n = 0;
|
|
1201
1201
|
return function() {
|
|
1202
1202
|
if (!t || n === 256) {
|
|
1203
|
-
for (t = "", n = (1 + e) / 2 | 0; n--;) t +=
|
|
1203
|
+
for (t = "", n = (1 + e) / 2 | 0; n--;) t += U[256 * Math.random() | 0];
|
|
1204
1204
|
t = t.substring(n = 0, e - 2);
|
|
1205
1205
|
}
|
|
1206
|
-
return t +
|
|
1206
|
+
return t + U[n++];
|
|
1207
1207
|
};
|
|
1208
1208
|
}
|
|
1209
1209
|
//#endregion
|
|
1210
1210
|
//#region src/utils/id.ts
|
|
1211
|
-
var
|
|
1211
|
+
var W = Oe(16), G = class {
|
|
1212
1212
|
entity = null;
|
|
1213
1213
|
$emit(e) {
|
|
1214
1214
|
if (!this.entity) throw Error("Entity is not set for this behavior.");
|
|
@@ -1229,7 +1229,7 @@ var Ee = Te(16), K = class {
|
|
|
1229
1229
|
$setEntity(e) {
|
|
1230
1230
|
this.entity = e;
|
|
1231
1231
|
}
|
|
1232
|
-
},
|
|
1232
|
+
}, K = class {
|
|
1233
1233
|
id;
|
|
1234
1234
|
type;
|
|
1235
1235
|
name;
|
|
@@ -1244,7 +1244,7 @@ var Ee = Te(16), K = class {
|
|
|
1244
1244
|
_tags = /* @__PURE__ */ new Set();
|
|
1245
1245
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1246
1246
|
constructor(e, t, n, r, i) {
|
|
1247
|
-
this.id =
|
|
1247
|
+
this.id = W(), this.type = e, this.name = i, this.state = n, this.eventBus = t;
|
|
1248
1248
|
for (let e of r) this.attachBehavior(new e());
|
|
1249
1249
|
}
|
|
1250
1250
|
get tags() {
|
|
@@ -1413,7 +1413,7 @@ var Ee = Te(16), K = class {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
return this.behaviors.splice(t, 1), n.$setEntity(null), !0;
|
|
1415
1415
|
}
|
|
1416
|
-
},
|
|
1416
|
+
}, ke = class {
|
|
1417
1417
|
eventBus;
|
|
1418
1418
|
entities = /* @__PURE__ */ new Map();
|
|
1419
1419
|
entityDefinitions = /* @__PURE__ */ new Map();
|
|
@@ -1537,7 +1537,7 @@ var Ee = Te(16), K = class {
|
|
|
1537
1537
|
let t = await n.onBeforeCreate(r);
|
|
1538
1538
|
t !== void 0 && (r = t);
|
|
1539
1539
|
}
|
|
1540
|
-
let i = t.name ?? n.name, a = new
|
|
1540
|
+
let i = t.name ?? n.name, a = new K(n.type, this.eventBus, r, n.behaviors, i);
|
|
1541
1541
|
if (a.$setEntityManager(this), t.node && a.$attachToNode(t.node, this._engine), n.tags) for (let e of n.tags) a.$addTag(e);
|
|
1542
1542
|
if (t.tags) for (let e of t.tags) a.$addTag(e);
|
|
1543
1543
|
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 +1707,18 @@ var Ee = Te(16), K = class {
|
|
|
1707
1707
|
}
|
|
1708
1708
|
this.entityDefinitions.clear(), this._entitiesByName.clear(), this._entitiesByType.clear(), this._entitiesByTag.clear(), this._entitiesByNode.clear(), this._log.info("EntityManager torn down successfully");
|
|
1709
1709
|
}
|
|
1710
|
-
},
|
|
1710
|
+
}, Ae = {
|
|
1711
1711
|
hable: h.TONEMAPPING_STANDARD,
|
|
1712
1712
|
reinhard: h.TONEMAPPING_STANDARD,
|
|
1713
1713
|
hejidawson: h.TONEMAPPING_STANDARD,
|
|
1714
1714
|
photographic: h.TONEMAPPING_STANDARD,
|
|
1715
1715
|
aces: h.TONEMAPPING_ACES
|
|
1716
1716
|
};
|
|
1717
|
-
function
|
|
1717
|
+
function je(e, t) {
|
|
1718
1718
|
if (!e.activeCamera) return;
|
|
1719
1719
|
t.volumetric && console.warn("[SAGE] Volumetric lighting requires renderer: \"frameGraph\". Ignored in pipeline mode.");
|
|
1720
1720
|
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 =
|
|
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 = Ae[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
1722
|
let n = new ne("sage-ssao", e, {
|
|
1723
1723
|
ssaoRatio: .5,
|
|
1724
1724
|
blurRatio: 1
|
|
@@ -1728,11 +1728,11 @@ function Ae(e, t) {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
//#endregion
|
|
1730
1730
|
//#region src/handlers/postProcessing.ts
|
|
1731
|
-
async function
|
|
1731
|
+
async function Me(e, t) {
|
|
1732
1732
|
if (t.renderer === "frameGraph") {
|
|
1733
1733
|
let { applyFrameGraphPostProcessing: n } = await import("./postProcessingFrameGraph-CaMgQzR-.js");
|
|
1734
1734
|
await n(e, t);
|
|
1735
|
-
} else
|
|
1735
|
+
} else je(e, t);
|
|
1736
1736
|
}
|
|
1737
1737
|
//#endregion
|
|
1738
1738
|
//#region src/utils/vectors.ts
|
|
@@ -1744,9 +1744,9 @@ function q(e) {
|
|
|
1744
1744
|
};
|
|
1745
1745
|
}
|
|
1746
1746
|
function J(e) {
|
|
1747
|
-
return new
|
|
1747
|
+
return new A(e.x, e.y, e.z);
|
|
1748
1748
|
}
|
|
1749
|
-
function
|
|
1749
|
+
function Ne(e) {
|
|
1750
1750
|
return {
|
|
1751
1751
|
x: e.x,
|
|
1752
1752
|
y: e.y,
|
|
@@ -1754,12 +1754,30 @@ function Me(e) {
|
|
|
1754
1754
|
w: e.w
|
|
1755
1755
|
};
|
|
1756
1756
|
}
|
|
1757
|
-
function
|
|
1758
|
-
return new
|
|
1757
|
+
function Pe(e) {
|
|
1758
|
+
return new w(e.x, e.y, e.z, e.w);
|
|
1759
|
+
}
|
|
1760
|
+
function Fe(e) {
|
|
1761
|
+
return v.Compose(e.scaling, e.rotationQuaternion ?? w.FromEulerVector(e.rotation), e.position);
|
|
1762
|
+
}
|
|
1763
|
+
function Ie(e) {
|
|
1764
|
+
e.computeWorldMatrix(!0);
|
|
1765
|
+
let t = Fe(e), n = e.parent;
|
|
1766
|
+
for (; n;) {
|
|
1767
|
+
n.computeWorldMatrix(!0);
|
|
1768
|
+
let e = Fe(n);
|
|
1769
|
+
e.determinant() >= 0 && (t = t.multiply(e)), n = n.parent;
|
|
1770
|
+
}
|
|
1771
|
+
let r = new A(), i = new w(), a = new A();
|
|
1772
|
+
return t.decompose(a, i, r), {
|
|
1773
|
+
position: r,
|
|
1774
|
+
rotation: i,
|
|
1775
|
+
scaling: a
|
|
1776
|
+
};
|
|
1759
1777
|
}
|
|
1760
1778
|
//#endregion
|
|
1761
1779
|
//#region src/classes/level.ts
|
|
1762
|
-
var
|
|
1780
|
+
var Le = class {
|
|
1763
1781
|
name;
|
|
1764
1782
|
_log;
|
|
1765
1783
|
_context;
|
|
@@ -1822,7 +1840,7 @@ var Pe = class {
|
|
|
1822
1840
|
this.outlines &&= (this.outlines.dispose(), null), this.clusteredLights &&= (this.clusteredLights.dispose(), null), this._scene.dispose(), this._scene = null;
|
|
1823
1841
|
}
|
|
1824
1842
|
}
|
|
1825
|
-
},
|
|
1843
|
+
}, Re = class {
|
|
1826
1844
|
_scene;
|
|
1827
1845
|
_layers = /* @__PURE__ */ new Map();
|
|
1828
1846
|
constructor(e, t) {
|
|
@@ -1866,7 +1884,7 @@ var Pe = class {
|
|
|
1866
1884
|
n.length > 0 && e.layer.addSelection(n);
|
|
1867
1885
|
}
|
|
1868
1886
|
}
|
|
1869
|
-
},
|
|
1887
|
+
}, ze = class extends Le {
|
|
1870
1888
|
_config;
|
|
1871
1889
|
_spawnPoints = [];
|
|
1872
1890
|
_entityNodes = [];
|
|
@@ -1888,9 +1906,9 @@ var Pe = class {
|
|
|
1888
1906
|
let n = e.createScene();
|
|
1889
1907
|
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) {
|
|
1890
1908
|
let e = this._config.postProcessing.renderer ?? "pipeline";
|
|
1891
|
-
this._log.info(`Applying post-processing with ${e} renderer`), await
|
|
1909
|
+
this._log.info(`Applying post-processing with ${e} renderer`), await Me(n, this._config.postProcessing);
|
|
1892
1910
|
}
|
|
1893
|
-
return this.outlines = new
|
|
1911
|
+
return this.outlines = new Re(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;
|
|
1894
1912
|
}
|
|
1895
1913
|
async _loadSceneFile(e) {
|
|
1896
1914
|
let t = this._getScenePath();
|
|
@@ -1921,11 +1939,11 @@ var Pe = class {
|
|
|
1921
1939
|
}
|
|
1922
1940
|
e.environmentTexture && e.createDefaultSkybox(e.environmentTexture, !0, t.skyboxSize ?? 1e3, 0, !1);
|
|
1923
1941
|
} else {
|
|
1924
|
-
let n = t.skyboxSize ?? 1e3, r =
|
|
1942
|
+
let n = t.skyboxSize ?? 1e3, r = b.CreateSphere("skybox", {
|
|
1925
1943
|
diameter: n,
|
|
1926
1944
|
segments: 32
|
|
1927
|
-
}, e), i = new
|
|
1928
|
-
i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new
|
|
1945
|
+
}, e), i = new O("skybox-mat", e);
|
|
1946
|
+
i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new ae(t.skybox, e), r.material = i, r.infiniteDistance = !0;
|
|
1929
1947
|
}
|
|
1930
1948
|
this._log.debug(`Skybox set from: ${t.skybox}`);
|
|
1931
1949
|
}
|
|
@@ -1961,19 +1979,19 @@ var Pe = class {
|
|
|
1961
1979
|
}
|
|
1962
1980
|
}
|
|
1963
1981
|
_createCamera(e, t, r) {
|
|
1964
|
-
let i = t.position ? J(t.position) :
|
|
1982
|
+
let i = t.position ? J(t.position) : A.Zero(), a;
|
|
1965
1983
|
switch (t.type) {
|
|
1966
1984
|
case "arcRotate": {
|
|
1967
|
-
let i = t.target ? J(t.target) :
|
|
1985
|
+
let i = t.target ? J(t.target) : A.Zero();
|
|
1968
1986
|
a = new n(e, t.alpha ?? Math.PI / 2, t.beta ?? Math.PI / 3, t.radius ?? 10, i, r);
|
|
1969
1987
|
break;
|
|
1970
1988
|
}
|
|
1971
1989
|
case "universal":
|
|
1972
|
-
a = new
|
|
1990
|
+
a = new oe(e, i, r);
|
|
1973
1991
|
break;
|
|
1974
1992
|
case "geospatial": {
|
|
1975
|
-
if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e,
|
|
1976
|
-
let n = new
|
|
1993
|
+
if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e, A.Zero(), r);
|
|
1994
|
+
let n = new le(e, r, { planetRadius: t.planetRadius });
|
|
1977
1995
|
t.center && (n.center = J(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;
|
|
1978
1996
|
break;
|
|
1979
1997
|
}
|
|
@@ -1984,7 +2002,7 @@ var Pe = class {
|
|
|
1984
2002
|
return this._applyCameraConfig(a, t), a;
|
|
1985
2003
|
}
|
|
1986
2004
|
_applyCameraConfig(e, t) {
|
|
1987
|
-
t.fov !== void 0 && (e.fov = t.fov), t.position && (e.position = J(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 = J(t.rotation))), e instanceof n && (t.target && e.setTarget(J(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
|
|
2005
|
+
t.fov !== void 0 && (e.fov = t.fov), t.position && (e.position = J(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 = J(t.rotation))), e instanceof n && (t.target && e.setTarget(J(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 le && (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 = J(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));
|
|
1988
2006
|
}
|
|
1989
2007
|
_processLights(e) {
|
|
1990
2008
|
let t = this._config.lights;
|
|
@@ -1994,7 +2012,7 @@ var Pe = class {
|
|
|
1994
2012
|
}
|
|
1995
2013
|
}
|
|
1996
2014
|
_createLight(e, t, n) {
|
|
1997
|
-
let r = t.direction ? J(t.direction) : new
|
|
2015
|
+
let r = t.direction ? J(t.direction) : new A(0, -1, 0), i = t.position ? J(t.position) : A.Zero();
|
|
1998
2016
|
switch (t.type) {
|
|
1999
2017
|
case "hemispheric": {
|
|
2000
2018
|
let i = new m(e, r, n);
|
|
@@ -2007,20 +2025,20 @@ var Pe = class {
|
|
|
2007
2025
|
break;
|
|
2008
2026
|
}
|
|
2009
2027
|
case "point": {
|
|
2010
|
-
let r = new
|
|
2028
|
+
let r = new te(e, i, n);
|
|
2011
2029
|
this._applyLightConfig(r, t);
|
|
2012
2030
|
break;
|
|
2013
2031
|
}
|
|
2014
2032
|
case "spot": {
|
|
2015
|
-
let a = new
|
|
2033
|
+
let a = new D(e, i, r, t.angle ?? Math.PI / 3, t.exponent ?? 2, n);
|
|
2016
2034
|
this._applyLightConfig(a, t);
|
|
2017
2035
|
break;
|
|
2018
2036
|
}
|
|
2019
2037
|
case "rectarea": {
|
|
2020
|
-
let a = new
|
|
2038
|
+
let a = new T(e, i, t.width ?? 1, t.height ?? 1, n);
|
|
2021
2039
|
if (this._applyLightConfig(a, t), t.direction) {
|
|
2022
|
-
let t = new
|
|
2023
|
-
t.position = a.position.clone(), a.position =
|
|
2040
|
+
let t = new k(`${e}_pivot`, n);
|
|
2041
|
+
t.position = a.position.clone(), a.position = A.Zero(), a.parent = t, t.lookAt(t.position.subtract(r));
|
|
2024
2042
|
}
|
|
2025
2043
|
break;
|
|
2026
2044
|
}
|
|
@@ -2032,22 +2050,22 @@ var Pe = class {
|
|
|
2032
2050
|
_setupClustering(e) {
|
|
2033
2051
|
let t = this._config.clustering;
|
|
2034
2052
|
if (!t?.enabled) return;
|
|
2035
|
-
let n = e.lights.filter((e) =>
|
|
2053
|
+
let n = e.lights.filter((e) => ue.IsLightSupported(e));
|
|
2036
2054
|
if (n.length === 0) {
|
|
2037
2055
|
this._log.debug("Clustering enabled but no eligible lights found");
|
|
2038
2056
|
return;
|
|
2039
2057
|
}
|
|
2040
2058
|
for (let t of n) e.removeLight(t);
|
|
2041
|
-
let r = new
|
|
2059
|
+
let r = new ue("sage-clustered", n, e);
|
|
2042
2060
|
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`);
|
|
2043
|
-
for (let t of e.materials) t instanceof
|
|
2061
|
+
for (let t of e.materials) t instanceof ee && (t.useGLTFLightFalloff = !0);
|
|
2044
2062
|
}
|
|
2045
2063
|
_toColor3(e) {
|
|
2046
2064
|
return new r(e.r, e.g, e.b);
|
|
2047
2065
|
}
|
|
2048
2066
|
async _enablePhysics(e) {
|
|
2049
|
-
let t = this._config.physics, n = new
|
|
2050
|
-
typeof t == "object" && t.gravity && (n = new
|
|
2067
|
+
let t = this._config.physics, n = new A(0, -9.81, 0);
|
|
2068
|
+
typeof t == "object" && t.gravity && (n = new A(t.gravity.x, t.gravity.y, t.gravity.z));
|
|
2051
2069
|
let r = this.gameEngine.largeWorldRendering ? 1e5 : void 0;
|
|
2052
2070
|
this._log.debug(`Enabling physics with gravity: ${n.toString()}`), await this.gameEngine.engines.sceneEngine.enablePhysics(e, n, r);
|
|
2053
2071
|
}
|
|
@@ -2068,13 +2086,17 @@ var Pe = class {
|
|
|
2068
2086
|
return t ? { ...t } : e.metadata;
|
|
2069
2087
|
}
|
|
2070
2088
|
async _processNodeMetadata(e) {
|
|
2071
|
-
"spawn" in e.metadata
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2089
|
+
if ("spawn" in e.metadata) {
|
|
2090
|
+
let { position: t, rotation: n, scaling: r } = Ie(e);
|
|
2091
|
+
this._spawnPoints.push({
|
|
2092
|
+
name: e.metadata.spawn,
|
|
2093
|
+
position: t,
|
|
2094
|
+
rotation: n,
|
|
2095
|
+
scaling: r,
|
|
2096
|
+
node: e
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
"entity" in e.metadata && this._entityNodes.push({
|
|
2078
2100
|
type: e.metadata.entity,
|
|
2079
2101
|
node: e
|
|
2080
2102
|
}), await this._runPropertyHandlers(e);
|
|
@@ -2104,7 +2126,7 @@ var Pe = class {
|
|
|
2104
2126
|
let n = {
|
|
2105
2127
|
...e.config,
|
|
2106
2128
|
position: q(t.position),
|
|
2107
|
-
rotation:
|
|
2129
|
+
rotation: Ne(t.rotation),
|
|
2108
2130
|
scaling: q(t.scaling)
|
|
2109
2131
|
}, r = await this.gameEngine.managers.entityManager.createEntity(e.entity, {
|
|
2110
2132
|
name: e.name,
|
|
@@ -2117,12 +2139,10 @@ var Pe = class {
|
|
|
2117
2139
|
if (!this._scene) return;
|
|
2118
2140
|
let n = this.gameEngine.managers.entityManager.getDefinition(e.type);
|
|
2119
2141
|
if (!n?.mesh) return;
|
|
2120
|
-
let r = n.mesh, i = this._scene, a = new
|
|
2121
|
-
a.position.copyFrom(t.position), a.rotationQuaternion = t.rotation.clone(), a.scaling.copyFrom(t.scaling);
|
|
2122
|
-
let o;
|
|
2142
|
+
let r = n.mesh, i = this._scene, a = new k(`entity-${e.id}`, i), o;
|
|
2123
2143
|
switch (r.source) {
|
|
2124
2144
|
case "box":
|
|
2125
|
-
o = [
|
|
2145
|
+
o = [b.CreateBox(`${e.type}-mesh`, {
|
|
2126
2146
|
size: r.params?.size ?? 1,
|
|
2127
2147
|
width: r.params?.width,
|
|
2128
2148
|
height: r.params?.height,
|
|
@@ -2130,19 +2150,19 @@ var Pe = class {
|
|
|
2130
2150
|
}, i)];
|
|
2131
2151
|
break;
|
|
2132
2152
|
case "sphere":
|
|
2133
|
-
o = [
|
|
2153
|
+
o = [b.CreateSphere(`${e.type}-mesh`, {
|
|
2134
2154
|
diameter: r.params?.diameter ?? 1,
|
|
2135
2155
|
segments: r.params?.segments ?? 16
|
|
2136
2156
|
}, i)];
|
|
2137
2157
|
break;
|
|
2138
2158
|
case "capsule":
|
|
2139
|
-
o = [
|
|
2159
|
+
o = [b.CreateCapsule(`${e.type}-mesh`, {
|
|
2140
2160
|
height: r.params?.height ?? 1.8,
|
|
2141
2161
|
radius: r.params?.radius ?? .4
|
|
2142
2162
|
}, i)];
|
|
2143
2163
|
break;
|
|
2144
2164
|
case "cylinder":
|
|
2145
|
-
o = [
|
|
2165
|
+
o = [b.CreateCylinder(`${e.type}-mesh`, {
|
|
2146
2166
|
height: r.params?.height ?? 1,
|
|
2147
2167
|
diameter: r.params?.diameter ?? 1
|
|
2148
2168
|
}, i)];
|
|
@@ -2159,21 +2179,21 @@ var Pe = class {
|
|
|
2159
2179
|
}
|
|
2160
2180
|
}
|
|
2161
2181
|
for (let e of o) e.parent ||= a;
|
|
2162
|
-
r.scale && (typeof r.scale == "number" ? a.scaling.setAll(r.scale) : a.scaling.set(r.scale.x, r.scale.y, r.scale.z));
|
|
2182
|
+
a.position.copyFrom(t.position), a.rotationQuaternion = t.rotation.clone(), a.scaling.copyFrom(t.scaling), r.scale && (typeof r.scale == "number" ? a.scaling.setAll(r.scale) : a.scaling.set(r.scale.x, r.scale.y, r.scale.z));
|
|
2163
2183
|
let s = r.material;
|
|
2164
2184
|
if (s?.color) {
|
|
2165
2185
|
let t = s.color;
|
|
2166
2186
|
if (s.type === "pbr") {
|
|
2167
|
-
let n = new
|
|
2187
|
+
let n = new ee(`${e.type}-material`, i);
|
|
2168
2188
|
n.albedoColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive)), n.metallic = s.metallic ?? 0, n.roughness = s.roughness ?? 1;
|
|
2169
2189
|
for (let e of o) e.material = n;
|
|
2170
2190
|
} else {
|
|
2171
|
-
let n = new
|
|
2191
|
+
let n = new O(`${e.type}-material`, i);
|
|
2172
2192
|
n.diffuseColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive));
|
|
2173
2193
|
for (let e of o) e.material = n;
|
|
2174
2194
|
}
|
|
2175
2195
|
}
|
|
2176
|
-
let c =
|
|
2196
|
+
let c = a.getDescendants(!1).filter((e) => e instanceof k);
|
|
2177
2197
|
for (let e of c) {
|
|
2178
2198
|
let t = this._getNormalizedMetadata(e);
|
|
2179
2199
|
t && Object.keys(t).length > 0 && (e.metadata = {
|
|
@@ -2222,7 +2242,7 @@ var Pe = class {
|
|
|
2222
2242
|
}
|
|
2223
2243
|
}
|
|
2224
2244
|
async onDeactivate() {
|
|
2225
|
-
for (let [e, t] of this._levelSounds) t.state ===
|
|
2245
|
+
for (let [e, t] of this._levelSounds) t.state === E.Started && (this._playingSoundsBeforeDeactivate.add(e), t.pause());
|
|
2226
2246
|
}
|
|
2227
2247
|
async onActivate() {
|
|
2228
2248
|
for (let e of this._playingSoundsBeforeDeactivate) {
|
|
@@ -2243,7 +2263,7 @@ var Pe = class {
|
|
|
2243
2263
|
for (let e of this._levelSounds.values()) e.dispose();
|
|
2244
2264
|
this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.$dispose();
|
|
2245
2265
|
}
|
|
2246
|
-
},
|
|
2266
|
+
}, Be = class {
|
|
2247
2267
|
_eventBus;
|
|
2248
2268
|
_gameEngine = null;
|
|
2249
2269
|
_log;
|
|
@@ -2296,7 +2316,7 @@ var Pe = class {
|
|
|
2296
2316
|
if (!n) throw Error(`Level class '${e.class}' is not registered.`);
|
|
2297
2317
|
return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
|
|
2298
2318
|
}
|
|
2299
|
-
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new
|
|
2319
|
+
return this._log.debug(`Creating level '${e.name}' using GameLevel`), new ze(e, t);
|
|
2300
2320
|
}
|
|
2301
2321
|
registerLevelConfig(e) {
|
|
2302
2322
|
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}`);
|
|
@@ -2382,7 +2402,7 @@ var Pe = class {
|
|
|
2382
2402
|
for (let e of this._loadedLevels.values()) await e.$dispose();
|
|
2383
2403
|
this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
|
|
2384
2404
|
}
|
|
2385
|
-
},
|
|
2405
|
+
}, Ve = class {
|
|
2386
2406
|
_audioEngine;
|
|
2387
2407
|
_channels = /* @__PURE__ */ new Map();
|
|
2388
2408
|
_masterMuted = !1;
|
|
@@ -2453,7 +2473,7 @@ var Pe = class {
|
|
|
2453
2473
|
getChannels() {
|
|
2454
2474
|
return Array.from(this._channels.keys());
|
|
2455
2475
|
}
|
|
2456
|
-
},
|
|
2476
|
+
}, He = class {
|
|
2457
2477
|
_entityManager;
|
|
2458
2478
|
_levelManager;
|
|
2459
2479
|
_log;
|
|
@@ -2543,7 +2563,7 @@ var Pe = class {
|
|
|
2543
2563
|
async $teardown() {
|
|
2544
2564
|
this._beforeSerializeHooks = [], this._afterDeserializeHooks = [], this._log.info("SaveManager torn down");
|
|
2545
2565
|
}
|
|
2546
|
-
},
|
|
2566
|
+
}, Ue = class {
|
|
2547
2567
|
_keyboardDevice;
|
|
2548
2568
|
_keysState = {};
|
|
2549
2569
|
_onDeviceConnected;
|
|
@@ -2608,7 +2628,7 @@ var Pe = class {
|
|
|
2608
2628
|
_notifyInputChanged(e) {
|
|
2609
2629
|
this._onInputChanged && this._onInputChanged(this._keyboardDevice, e);
|
|
2610
2630
|
}
|
|
2611
|
-
},
|
|
2631
|
+
}, We = class {
|
|
2612
2632
|
_targetElement;
|
|
2613
2633
|
_mouseDevice;
|
|
2614
2634
|
_buttonState = {};
|
|
@@ -2727,7 +2747,7 @@ var Pe = class {
|
|
|
2727
2747
|
_notifyInputChanged(e) {
|
|
2728
2748
|
this._onInputChanged && this._onInputChanged(this._mouseDevice, e);
|
|
2729
2749
|
}
|
|
2730
|
-
},
|
|
2750
|
+
}, Ge = class {
|
|
2731
2751
|
_gamepadDevices = {};
|
|
2732
2752
|
_buttonStates = {};
|
|
2733
2753
|
_axesStates = {};
|
|
@@ -2861,14 +2881,14 @@ var Pe = class {
|
|
|
2861
2881
|
_notifyInputChanged(e, t) {
|
|
2862
2882
|
this._onInputChanged && this._onInputChanged(e, t);
|
|
2863
2883
|
}
|
|
2864
|
-
},
|
|
2884
|
+
}, Ke = class {
|
|
2865
2885
|
_eventBus;
|
|
2866
2886
|
_keyboardRA;
|
|
2867
2887
|
_mouseRA;
|
|
2868
2888
|
_gamepadRA;
|
|
2869
2889
|
_log;
|
|
2870
2890
|
constructor(e, t, n) {
|
|
2871
|
-
this._eventBus = e, this._log = n?.getLogger("UserInputManager") || new M("UserInputManager"), this._log.info("Initializing UserInputManager"), this._log.debug("Initializing input resource access classes"), this._keyboardRA = new
|
|
2891
|
+
this._eventBus = e, this._log = n?.getLogger("UserInputManager") || new M("UserInputManager"), this._log.info("Initializing UserInputManager"), this._log.debug("Initializing input resource access classes"), this._keyboardRA = new Ue(), this._mouseRA = new We(t), this._gamepadRA = new Ge(), 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");
|
|
2872
2892
|
}
|
|
2873
2893
|
_publishDeviceConnected(e) {
|
|
2874
2894
|
this._log.debug(`Device connected: ${e.id} (${e.name})`), this._eventBus.publish({
|
|
@@ -2921,18 +2941,18 @@ var Pe = class {
|
|
|
2921
2941
|
};
|
|
2922
2942
|
//#endregion
|
|
2923
2943
|
//#region src/utils/graphics.ts
|
|
2924
|
-
async function
|
|
2925
|
-
let n = new
|
|
2944
|
+
async function qe(e, t) {
|
|
2945
|
+
let n = new se(e, t);
|
|
2926
2946
|
return await n.initAsync(), n;
|
|
2927
2947
|
}
|
|
2928
2948
|
function Y(e, t) {
|
|
2929
2949
|
return new l(e, t.antialias, t.options, t.adaptToDeviceRatio);
|
|
2930
2950
|
}
|
|
2931
|
-
function
|
|
2932
|
-
return new
|
|
2951
|
+
function Je(e) {
|
|
2952
|
+
return new x(e);
|
|
2933
2953
|
}
|
|
2934
|
-
async function
|
|
2935
|
-
if (e === null) return console.debug("Using Null Engine"),
|
|
2954
|
+
async function Ye(e, t, n = !1) {
|
|
2955
|
+
if (e === null) return console.debug("Using Null Engine"), Je(t);
|
|
2936
2956
|
if (n) if ("options" in t) {
|
|
2937
2957
|
let e = t;
|
|
2938
2958
|
t = {
|
|
@@ -2947,15 +2967,15 @@ async function Ke(e, t, n = !1) {
|
|
|
2947
2967
|
useLargeWorldRendering: !0
|
|
2948
2968
|
};
|
|
2949
2969
|
let r = t.engine || "auto";
|
|
2950
|
-
if (r === "webgpu") if (
|
|
2951
|
-
return console.debug("Using forced WebGPU engine"), await
|
|
2970
|
+
if (r === "webgpu") if (V()) try {
|
|
2971
|
+
return console.debug("Using forced WebGPU engine"), await qe(e, t);
|
|
2952
2972
|
} catch (e) {
|
|
2953
2973
|
throw console.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
|
|
2954
2974
|
}
|
|
2955
2975
|
else throw Error("WebGPU was forced but is not available in this browser.");
|
|
2956
2976
|
if (r === "webgl") return console.debug("Using forced WebGL engine"), Y(e, t);
|
|
2957
|
-
if (
|
|
2958
|
-
return console.debug("Using WebGPU"),
|
|
2977
|
+
if (V()) try {
|
|
2978
|
+
return console.debug("Using WebGPU"), qe(e, t).catch((n) => (console.warn("WebGPU initialization failed, falling back to WebGL:", n), Y(e, t)));
|
|
2959
2979
|
} catch (e) {
|
|
2960
2980
|
console.warn("WebGPU initialization failed, falling back to WebGL:", e);
|
|
2961
2981
|
}
|
|
@@ -2964,15 +2984,15 @@ async function Ke(e, t, n = !1) {
|
|
|
2964
2984
|
}
|
|
2965
2985
|
//#endregion
|
|
2966
2986
|
//#region src/utils/physics.ts
|
|
2967
|
-
async function
|
|
2968
|
-
return await
|
|
2987
|
+
async function Xe() {
|
|
2988
|
+
return await de();
|
|
2969
2989
|
}
|
|
2970
|
-
function
|
|
2990
|
+
function Ze(e) {
|
|
2971
2991
|
return new p(!0, e);
|
|
2972
2992
|
}
|
|
2973
2993
|
//#endregion
|
|
2974
2994
|
//#region src/utils/raycast.ts
|
|
2975
|
-
var
|
|
2995
|
+
var Qe = class {
|
|
2976
2996
|
_entityManager;
|
|
2977
2997
|
constructor(e) {
|
|
2978
2998
|
this._entityManager = e;
|
|
@@ -3038,7 +3058,7 @@ var Ye = class {
|
|
|
3038
3058
|
pickingInfo: e
|
|
3039
3059
|
};
|
|
3040
3060
|
}
|
|
3041
|
-
},
|
|
3061
|
+
}, $e = class {
|
|
3042
3062
|
_nextId = 0;
|
|
3043
3063
|
_delays = [];
|
|
3044
3064
|
_intervals = [];
|
|
@@ -3093,14 +3113,14 @@ var Ye = class {
|
|
|
3093
3113
|
for (let t of this._intervals) for (t.elapsed += e; t.elapsed >= t.periodMs;) t.callback(), t.elapsed -= t.periodMs;
|
|
3094
3114
|
for (let t of this._cooldowns) t.remaining > 0 && (t.remaining = Math.max(0, t.remaining - e));
|
|
3095
3115
|
}
|
|
3096
|
-
},
|
|
3116
|
+
}, et = [
|
|
3097
3117
|
"trace",
|
|
3098
3118
|
"debug",
|
|
3099
3119
|
"info",
|
|
3100
3120
|
"warn",
|
|
3101
3121
|
"error",
|
|
3102
3122
|
"none"
|
|
3103
|
-
],
|
|
3123
|
+
], tt = class extends G {
|
|
3104
3124
|
name = "sound";
|
|
3105
3125
|
eventSubscriptions = [];
|
|
3106
3126
|
_sounds = /* @__PURE__ */ new Map();
|
|
@@ -3169,7 +3189,7 @@ var Ye = class {
|
|
|
3169
3189
|
} else for (let t of this._sounds.values()) t.volume = e;
|
|
3170
3190
|
}
|
|
3171
3191
|
isPlaying(e) {
|
|
3172
|
-
return this._getSound(e)?.state ===
|
|
3192
|
+
return this._getSound(e)?.state === E.Started;
|
|
3173
3193
|
}
|
|
3174
3194
|
getSoundNames() {
|
|
3175
3195
|
return Array.from(this._sounds.keys());
|
|
@@ -3245,7 +3265,7 @@ var Ye = class {
|
|
|
3245
3265
|
}
|
|
3246
3266
|
});
|
|
3247
3267
|
}
|
|
3248
|
-
},
|
|
3268
|
+
}, nt = class extends G {
|
|
3249
3269
|
name = "stateMachine";
|
|
3250
3270
|
eventSubscriptions = [];
|
|
3251
3271
|
stateMachine;
|
|
@@ -3264,7 +3284,7 @@ var Ye = class {
|
|
|
3264
3284
|
}
|
|
3265
3285
|
static create(e) {
|
|
3266
3286
|
let { initialState: t, stateKey: n, transitions: r, wildcardTransitions: i } = e;
|
|
3267
|
-
class a extends
|
|
3287
|
+
class a extends nt {
|
|
3268
3288
|
constructor() {
|
|
3269
3289
|
super(), this.stateKey = n, this.stateMachine = new X(t);
|
|
3270
3290
|
for (let e of r) this.stateMachine.addTransition(e.from, e.to, e.guard);
|
|
@@ -3276,55 +3296,52 @@ var Ye = class {
|
|
|
3276
3296
|
}, Z = new M("ColliderHandler");
|
|
3277
3297
|
function Q(e, t, n) {
|
|
3278
3298
|
let r = e.getScene();
|
|
3279
|
-
new
|
|
3299
|
+
new S(e, t, { mass: n }, r);
|
|
3280
3300
|
}
|
|
3281
|
-
function
|
|
3301
|
+
function rt(e, t) {
|
|
3282
3302
|
let n = e.getChildMeshes().find((e) => e.metadata?.collider_mesh === !0);
|
|
3283
|
-
n instanceof
|
|
3303
|
+
n instanceof y ? (n.isVisible = !1, Q(n, C.MESH, t)) : Q(e, C.MESH, t);
|
|
3284
3304
|
}
|
|
3285
|
-
function
|
|
3305
|
+
function it(t) {
|
|
3286
3306
|
t.registerPropertyHandler("collider", (t, n, r, i) => {
|
|
3287
3307
|
let a = n;
|
|
3288
|
-
if (Z.debug(`Processing collider: ${t.name} -> ${a} (isMesh: ${t instanceof
|
|
3289
|
-
if (!(t instanceof
|
|
3308
|
+
if (Z.debug(`Processing collider: ${t.name} -> ${a} (isMesh: ${t instanceof y})`), !r.scene) throw Error("Scene not available for collider handler");
|
|
3309
|
+
if (!(t instanceof y) && a === "mesh") {
|
|
3290
3310
|
Z.warn(`Skipping mesh collider for ${t.name}: not a Mesh instance`);
|
|
3291
3311
|
return;
|
|
3292
3312
|
}
|
|
3293
3313
|
let o = t.metadata?.collider_mass ?? 0;
|
|
3294
3314
|
switch (a) {
|
|
3295
3315
|
case "box":
|
|
3296
|
-
Q(t,
|
|
3316
|
+
Q(t, C.BOX, o);
|
|
3297
3317
|
break;
|
|
3298
3318
|
case "sphere":
|
|
3299
|
-
Q(t,
|
|
3319
|
+
Q(t, C.SPHERE, o);
|
|
3300
3320
|
break;
|
|
3301
3321
|
case "mesh":
|
|
3302
|
-
|
|
3322
|
+
rt(t, o);
|
|
3303
3323
|
break;
|
|
3304
3324
|
case "none":
|
|
3305
3325
|
t instanceof e && (t.checkCollisions = !1);
|
|
3306
3326
|
break;
|
|
3307
3327
|
default: Z.warn(`Unknown collider type: ${a}`);
|
|
3308
3328
|
}
|
|
3309
|
-
|
|
3310
|
-
let e = t;
|
|
3311
|
-
e.physicsBody && (e.physicsBody.disablePreStep = !1);
|
|
3312
|
-
}
|
|
3329
|
+
t.metadata?.collider_kinematic && t instanceof e && t.physicsBody && (t.physicsBody.disablePreStep = !1);
|
|
3313
3330
|
});
|
|
3314
3331
|
}
|
|
3315
3332
|
//#endregion
|
|
3316
3333
|
//#region src/handlers/lod.ts
|
|
3317
|
-
var
|
|
3318
|
-
function
|
|
3334
|
+
var at = new M("LodHandler");
|
|
3335
|
+
function ot(e) {
|
|
3319
3336
|
return e.split(",").map((e) => parseFloat(e.trim())).filter((e) => !isNaN(e));
|
|
3320
3337
|
}
|
|
3321
|
-
function
|
|
3338
|
+
function st(e) {
|
|
3322
3339
|
e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
|
|
3323
3340
|
let i = t;
|
|
3324
|
-
if (!(e instanceof
|
|
3325
|
-
let a =
|
|
3341
|
+
if (!(e instanceof y)) return;
|
|
3342
|
+
let a = ot(i);
|
|
3326
3343
|
if (a.length === 0) {
|
|
3327
|
-
|
|
3344
|
+
at.warn(`Invalid lod_distances value: ${i}`);
|
|
3328
3345
|
return;
|
|
3329
3346
|
}
|
|
3330
3347
|
let o = e.getChildMeshes(!0), s = Math.min(a.length, o.length);
|
|
@@ -3337,12 +3354,12 @@ function it(e) {
|
|
|
3337
3354
|
//#region src/handlers/occluder.ts
|
|
3338
3355
|
function $(e) {
|
|
3339
3356
|
e.registerPropertyHandler("occluder", (e, t, n, r) => {
|
|
3340
|
-
t && e instanceof
|
|
3357
|
+
t && e instanceof y && (e.isOccluder = !0, e.isVisible = !1);
|
|
3341
3358
|
});
|
|
3342
3359
|
}
|
|
3343
3360
|
//#endregion
|
|
3344
3361
|
//#region src/utils/metadata.ts
|
|
3345
|
-
function
|
|
3362
|
+
function ct(e, t) {
|
|
3346
3363
|
let n = {}, r = `${t}_`;
|
|
3347
3364
|
for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
|
|
3348
3365
|
let e = t.slice(r.length);
|
|
@@ -3352,14 +3369,14 @@ function at(e, t) {
|
|
|
3352
3369
|
}
|
|
3353
3370
|
//#endregion
|
|
3354
3371
|
//#region src/handlers/sound.ts
|
|
3355
|
-
var
|
|
3356
|
-
function
|
|
3372
|
+
var lt = new M("SoundHandler");
|
|
3373
|
+
function ut(e) {
|
|
3357
3374
|
e.registerPropertyHandler("sound", (e, t, n, r) => {
|
|
3358
3375
|
let i = t;
|
|
3359
3376
|
if (!n.scene) throw Error("Scene not available for sound handler");
|
|
3360
|
-
let a =
|
|
3377
|
+
let a = ct(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;
|
|
3361
3378
|
if (!f) {
|
|
3362
|
-
|
|
3379
|
+
lt.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
|
|
3363
3380
|
return;
|
|
3364
3381
|
}
|
|
3365
3382
|
f.createSound(`${e.name}_sound`, i, d, {
|
|
@@ -3372,13 +3389,13 @@ function st(e) {
|
|
|
3372
3389
|
}).then((t) => {
|
|
3373
3390
|
c && t.spatial.attach(e);
|
|
3374
3391
|
}).catch((t) => {
|
|
3375
|
-
|
|
3392
|
+
lt.error(`Failed to create sound for node "${e.name}": ${t}`);
|
|
3376
3393
|
});
|
|
3377
3394
|
});
|
|
3378
3395
|
}
|
|
3379
3396
|
//#endregion
|
|
3380
3397
|
//#region src/handlers/trigger.ts
|
|
3381
|
-
function
|
|
3398
|
+
function dt(e, n, r, i, a) {
|
|
3382
3399
|
let o = a === "enter" ? t.OnIntersectionEnterTrigger : t.OnIntersectionExitTrigger, s = `trigger:${a}`;
|
|
3383
3400
|
e.registerAction(new u({
|
|
3384
3401
|
trigger: o,
|
|
@@ -3393,10 +3410,10 @@ function ct(e, n, r, i, a) {
|
|
|
3393
3410
|
});
|
|
3394
3411
|
}));
|
|
3395
3412
|
}
|
|
3396
|
-
function
|
|
3397
|
-
|
|
3413
|
+
function ft(e, t, n, r) {
|
|
3414
|
+
dt(e, t, n, r, "enter"), dt(e, t, n, r, "exit");
|
|
3398
3415
|
}
|
|
3399
|
-
function
|
|
3416
|
+
function pt(n) {
|
|
3400
3417
|
n.registerPropertyHandler("trigger", (n, r, i, a) => {
|
|
3401
3418
|
let o = r, s = i.scene;
|
|
3402
3419
|
if (!s) throw Error("Scene not available for trigger handler");
|
|
@@ -3405,9 +3422,9 @@ function ut(n) {
|
|
|
3405
3422
|
n.isVisible = !1, n.checkCollisions = !0;
|
|
3406
3423
|
let l = n.actionManager ?? new t(s);
|
|
3407
3424
|
n.actionManager = l;
|
|
3408
|
-
for (let e of s.meshes) e !== n && !e.metadata?.trigger &&
|
|
3425
|
+
for (let e of s.meshes) e !== n && !e.metadata?.trigger && ft(l, o, c, e);
|
|
3409
3426
|
let u = s.onNewMeshAddedObservable.add((e) => {
|
|
3410
|
-
e !== n && !e.metadata?.trigger &&
|
|
3427
|
+
e !== n && !e.metadata?.trigger && ft(l, o, c, e);
|
|
3411
3428
|
});
|
|
3412
3429
|
n.onDisposeObservable.add(() => {
|
|
3413
3430
|
s.onNewMeshAddedObservable.remove(u);
|
|
@@ -3416,7 +3433,7 @@ function ut(n) {
|
|
|
3416
3433
|
}
|
|
3417
3434
|
//#endregion
|
|
3418
3435
|
//#region src/handlers/visible.ts
|
|
3419
|
-
function
|
|
3436
|
+
function mt(t) {
|
|
3420
3437
|
t.registerPropertyHandler("visible", (t, n, r, i) => {
|
|
3421
3438
|
if (!(t instanceof e)) return;
|
|
3422
3439
|
let a = !0;
|
|
@@ -3425,37 +3442,37 @@ function dt(t) {
|
|
|
3425
3442
|
}
|
|
3426
3443
|
//#endregion
|
|
3427
3444
|
//#region src/handlers/index.ts
|
|
3428
|
-
function
|
|
3429
|
-
|
|
3445
|
+
function ht(e) {
|
|
3446
|
+
it(e), st(e), $(e), ut(e), pt(e), mt(e);
|
|
3430
3447
|
}
|
|
3431
3448
|
//#endregion
|
|
3432
3449
|
//#region src/sage.ts
|
|
3433
|
-
async function
|
|
3434
|
-
let r = new
|
|
3435
|
-
i.info(`Initializing SAGE Game Engine v${
|
|
3436
|
-
let a = await
|
|
3450
|
+
async function gt(e, t, n = {}) {
|
|
3451
|
+
let r = new he(n.logLevel || "debug"), i = r.getLogger("SAGE");
|
|
3452
|
+
i.info(`Initializing SAGE Game Engine v${j}...`), i.debug("Creating rendering engine...");
|
|
3453
|
+
let a = await Ye(e, {
|
|
3437
3454
|
antialias: !0,
|
|
3438
3455
|
adaptToDeviceRatio: !0,
|
|
3439
3456
|
...n.renderOptions
|
|
3440
3457
|
}, n.largeWorldRendering ?? !1);
|
|
3441
3458
|
i.debug("Creating physics engine...");
|
|
3442
|
-
let o = await
|
|
3459
|
+
let o = await Xe(), s = Ze(o);
|
|
3443
3460
|
i.debug("Creating event bus...");
|
|
3444
|
-
let c = new
|
|
3461
|
+
let c = new ge(r);
|
|
3445
3462
|
i.debug("Creating scene engine...");
|
|
3446
|
-
let l = new
|
|
3463
|
+
let l = new P(e, a, o, r);
|
|
3447
3464
|
i.debug("Creating managers...");
|
|
3448
|
-
let u = new
|
|
3465
|
+
let u = new F(c, l, r), d = new Ke(c, e, r), f = new Ee(c, r), p = new ke(c, r, f), m = new Be(c, r), h = new He(p, m, r), g = new De(a, c, p, d, m, r);
|
|
3449
3466
|
i.debug("Creating raycast helper...");
|
|
3450
|
-
let _ = new
|
|
3467
|
+
let _ = new Qe(p);
|
|
3451
3468
|
i.debug("Creating game timer...");
|
|
3452
|
-
let v = new
|
|
3469
|
+
let v = new $e();
|
|
3453
3470
|
g.registerFrameCallback((e) => v.tick(e * 1e3));
|
|
3454
3471
|
let y, b;
|
|
3455
|
-
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), y = new
|
|
3472
|
+
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), y = new N(r), await y.initialize(), i.debug("Creating audio manager..."), b = new Ve(y, r), await b.initialize(n.audioChannels)), i.info(`SAGE Game Engine v${j} initialized successfully.`), i.debug("Loading entities...");
|
|
3456
3473
|
for (let e of t) p.registerEntityDefinition(e);
|
|
3457
3474
|
if (i.debug("Registering default input bindings..."), n.bindings) for (let e of n.bindings) f.registerBinding(e);
|
|
3458
|
-
let x = new
|
|
3475
|
+
let x = new fe(e, a, s, c, r, _, v, {
|
|
3459
3476
|
sceneEngine: l,
|
|
3460
3477
|
audioEngine: y
|
|
3461
3478
|
}, {
|
|
@@ -3471,6 +3488,6 @@ async function pt(e, t, n = {}) {
|
|
|
3471
3488
|
return p.$setGameEngine(x), m.$setGameEngine(x), x;
|
|
3472
3489
|
}
|
|
3473
3490
|
//#endregion
|
|
3474
|
-
export {
|
|
3491
|
+
export { F as AssetManager, N as AudioEngine, Ve as AudioManager, pe as ConsoleBackend, fe as GameEngine, K as GameEntity, G as GameEntityBehavior, ge as GameEventBus, ze as GameLevel, $e as GameTimer, Le as Level, et as LogLevels, he as LoggingUtility, me as NullBackend, Re as OutlineManager, Qe as RaycastHelper, M as SAGELogger, He as SaveManager, P as SceneEngine, tt as SoundBehavior, X as StateMachine, nt as StateMachineBehavior, j as VERSION, Me as applyPostProcessing, I as bindingTypes, ct as collectPrefixedProperties, gt as createGameEngine, W as generateId, Ie as getCanonicalTransform, z as isGamepadState, L as isKeyboardState, R as isMouseState, ht as registerAllPropertyHandlers, it as registerColliderHandler, st as registerLodHandler, $ as registerOccluderHandler, ut as registerSoundHandler, pt as registerTriggerHandler, mt as registerVisibleHandler, Ne as toQuatObject, Pe as toQuaternion, q as toVec3Object, J as toVector3, _e as validDeviceTypes };
|
|
3475
3492
|
|
|
3476
3493
|
//# sourceMappingURL=sage.es.js.map
|