@skewedaspect/sage 0.9.0 → 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 +9 -8
- package/dist/interfaces/level.d.ts +9 -0
- package/dist/sage.d.ts +1 -0
- package/dist/sage.es.js +232 -192
- 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 +35 -0
- 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
|
|
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
2
|
import { registerBuiltInLoaders as ce } from "@babylonjs/loaders/dynamic";
|
|
3
3
|
import { GeospatialCamera as le } from "@babylonjs/core/Cameras/geospatialCamera";
|
|
4
4
|
import { ClusteredLightContainer as ue } from "@babylonjs/core/Lights/Clustered/clusteredLightContainer";
|
|
5
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 k = "0.9.0", fe = 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);
|
|
@@ -139,7 +139,7 @@ var k = "0.9.0", fe = class {
|
|
|
139
139
|
error(e, t, ...n) {}
|
|
140
140
|
time(e, t) {}
|
|
141
141
|
timeEnd(e, t) {}
|
|
142
|
-
},
|
|
142
|
+
}, M = class {
|
|
143
143
|
category;
|
|
144
144
|
backend;
|
|
145
145
|
minLevel;
|
|
@@ -181,7 +181,7 @@ var k = "0.9.0", fe = class {
|
|
|
181
181
|
default: return !1;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
},
|
|
184
|
+
}, he = class {
|
|
185
185
|
backend;
|
|
186
186
|
level;
|
|
187
187
|
loggers;
|
|
@@ -190,12 +190,12 @@ var k = "0.9.0", fe = class {
|
|
|
190
190
|
}
|
|
191
191
|
setBackend(e) {
|
|
192
192
|
this.backend = e, this.loggers.forEach((e) => {
|
|
193
|
-
e instanceof
|
|
193
|
+
e instanceof M && e.updateSettings(this.backend, this.level);
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
setLevel(e) {
|
|
197
197
|
this.level = e, this.loggers.forEach((e) => {
|
|
198
|
-
e instanceof
|
|
198
|
+
e instanceof M && e.updateSettings(this.backend, this.level);
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
getLevel() {
|
|
@@ -203,14 +203,14 @@ var k = "0.9.0", fe = class {
|
|
|
203
203
|
}
|
|
204
204
|
getLogger(e) {
|
|
205
205
|
let t = this.loggers.get(e);
|
|
206
|
-
return t || (t = new
|
|
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;
|
|
212
212
|
constructor(e) {
|
|
213
|
-
this._log = e?.getLogger("EventBus") || new
|
|
213
|
+
this._log = e?.getLogger("EventBus") || new M("EventBus");
|
|
214
214
|
}
|
|
215
215
|
subscribe(e, t) {
|
|
216
216
|
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);
|
|
@@ -311,14 +311,14 @@ var P = 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);
|
|
@@ -333,28 +333,28 @@ var P = class {
|
|
|
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 P = 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 P = 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,
|
|
@@ -380,7 +380,7 @@ var P = class {
|
|
|
380
380
|
async loadModel(e, t) {
|
|
381
381
|
this._log.debug(`Loading model: ${e}`);
|
|
382
382
|
try {
|
|
383
|
-
let n = await
|
|
383
|
+
let n = await _(`${e}`, t);
|
|
384
384
|
return this._log.debug(`Model loaded successfully: ${e}`), n;
|
|
385
385
|
} catch (t) {
|
|
386
386
|
throw this._log.error(`Failed to load model: ${e}`, t), t;
|
|
@@ -405,7 +405,7 @@ var P = class {
|
|
|
405
405
|
_containers = /* @__PURE__ */ new Map();
|
|
406
406
|
_sourceMeshes = /* @__PURE__ */ new Map();
|
|
407
407
|
constructor(e, t, n) {
|
|
408
|
-
this._eventBus = e, this._sceneEngine = t, this._log = n?.getLogger("AssetManager") ?? new
|
|
408
|
+
this._eventBus = e, this._sceneEngine = t, this._log = n?.getLogger("AssetManager") ?? new M("AssetManager");
|
|
409
409
|
}
|
|
410
410
|
_parsePath(e) {
|
|
411
411
|
let t = e.indexOf("#");
|
|
@@ -495,7 +495,7 @@ var P = class {
|
|
|
495
495
|
"trigger",
|
|
496
496
|
"toggle",
|
|
497
497
|
"value"
|
|
498
|
-
],
|
|
498
|
+
], _e = [
|
|
499
499
|
"keyboard",
|
|
500
500
|
"mouse",
|
|
501
501
|
"gamepad"
|
|
@@ -511,7 +511,7 @@ function z(e) {
|
|
|
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 ge = 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 ge = 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 ge = 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 ge = 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 ge = 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 ge = 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();
|
|
@@ -831,7 +831,7 @@ var ge = class {
|
|
|
831
831
|
this._eventBus = e, this._inputUnsubscribe = this._eventBus.subscribe("input:changed", (e) => {
|
|
832
832
|
let t = e.payload;
|
|
833
833
|
t && this.$handleInput(t.device, t.state);
|
|
834
|
-
}), this._log = t?.getLogger("BindingManager") || new
|
|
834
|
+
}), this._log = t?.getLogger("BindingManager") || new M("BindingManager"), this._log.debug("BindingManager initialized");
|
|
835
835
|
}
|
|
836
836
|
_isBindingContextActive(e) {
|
|
837
837
|
return e.context ? this._activeContexts.has(e.context) : !0;
|
|
@@ -849,22 +849,22 @@ var ge = class {
|
|
|
849
849
|
return t;
|
|
850
850
|
}
|
|
851
851
|
_shouldUpdateActiveDevice(e) {
|
|
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) >
|
|
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 ge = 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
|
}
|
|
@@ -925,7 +925,7 @@ var ge = 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",
|
|
@@ -1118,7 +1118,7 @@ function V() {
|
|
|
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 Te = 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
|
|
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;
|
|
@@ -1195,7 +1195,7 @@ for (var Te = class {
|
|
|
1195
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
1197
|
}, H = 256, U = []; H--;) U[H] = (H + 256).toString(16).substring(1);
|
|
1198
|
-
function
|
|
1198
|
+
function Oe(e) {
|
|
1199
1199
|
e ||= 16;
|
|
1200
1200
|
var t = "", n = 0;
|
|
1201
1201
|
return function() {
|
|
@@ -1208,7 +1208,7 @@ function Ee(e) {
|
|
|
1208
1208
|
}
|
|
1209
1209
|
//#endregion
|
|
1210
1210
|
//#region src/utils/id.ts
|
|
1211
|
-
var W =
|
|
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.");
|
|
@@ -1413,7 +1413,7 @@ var W = Ee(16), G = 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();
|
|
@@ -1426,7 +1426,7 @@ var W = Ee(16), G = class {
|
|
|
1426
1426
|
_entitiesByNode = /* @__PURE__ */ new Map();
|
|
1427
1427
|
_pools = /* @__PURE__ */ new Map();
|
|
1428
1428
|
constructor(e, t, n) {
|
|
1429
|
-
this.eventBus = e, this.bindingManager = n, this._log = t?.getLogger("EntityManager") || new
|
|
1429
|
+
this.eventBus = e, this.bindingManager = n, this._log = t?.getLogger("EntityManager") || new M("EntityManager"), this._log.info("EntityManager initialized");
|
|
1430
1430
|
}
|
|
1431
1431
|
$setGameEngine(e) {
|
|
1432
1432
|
this._gameEngine = e;
|
|
@@ -1707,18 +1707,18 @@ var W = Ee(16), G = 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,15 +1728,56 @@ function ke(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
|
+
}
|
|
1737
|
+
//#endregion
|
|
1738
|
+
//#region src/utils/vectors.ts
|
|
1739
|
+
function q(e) {
|
|
1740
|
+
return {
|
|
1741
|
+
x: e.x,
|
|
1742
|
+
y: e.y,
|
|
1743
|
+
z: e.z
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function J(e) {
|
|
1747
|
+
return new A(e.x, e.y, e.z);
|
|
1748
|
+
}
|
|
1749
|
+
function Ne(e) {
|
|
1750
|
+
return {
|
|
1751
|
+
x: e.x,
|
|
1752
|
+
y: e.y,
|
|
1753
|
+
z: e.z,
|
|
1754
|
+
w: e.w
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
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
|
+
};
|
|
1736
1777
|
}
|
|
1737
1778
|
//#endregion
|
|
1738
1779
|
//#region src/classes/level.ts
|
|
1739
|
-
var
|
|
1780
|
+
var Le = class {
|
|
1740
1781
|
name;
|
|
1741
1782
|
_log;
|
|
1742
1783
|
_context;
|
|
@@ -1744,7 +1785,7 @@ var J = class {
|
|
|
1744
1785
|
clusteredLights = null;
|
|
1745
1786
|
outlines = null;
|
|
1746
1787
|
constructor(e, t) {
|
|
1747
|
-
this.name = e.name, this._context = t, this._log = t.logger?.getLogger(`Level:${e.name}`) ?? new
|
|
1788
|
+
this.name = e.name, this._context = t, this._log = t.logger?.getLogger(`Level:${e.name}`) ?? new M(`Level:${e.name}`, "info");
|
|
1748
1789
|
}
|
|
1749
1790
|
get scene() {
|
|
1750
1791
|
return this._scene;
|
|
@@ -1799,7 +1840,7 @@ var J = class {
|
|
|
1799
1840
|
this.outlines &&= (this.outlines.dispose(), null), this.clusteredLights &&= (this.clusteredLights.dispose(), null), this._scene.dispose(), this._scene = null;
|
|
1800
1841
|
}
|
|
1801
1842
|
}
|
|
1802
|
-
},
|
|
1843
|
+
}, Re = class {
|
|
1803
1844
|
_scene;
|
|
1804
1845
|
_layers = /* @__PURE__ */ new Map();
|
|
1805
1846
|
constructor(e, t) {
|
|
@@ -1843,7 +1884,7 @@ var J = class {
|
|
|
1843
1884
|
n.length > 0 && e.layer.addSelection(n);
|
|
1844
1885
|
}
|
|
1845
1886
|
}
|
|
1846
|
-
},
|
|
1887
|
+
}, ze = class extends Le {
|
|
1847
1888
|
_config;
|
|
1848
1889
|
_spawnPoints = [];
|
|
1849
1890
|
_entityNodes = [];
|
|
@@ -1865,9 +1906,9 @@ var J = class {
|
|
|
1865
1906
|
let n = e.createScene();
|
|
1866
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) {
|
|
1867
1908
|
let e = this._config.postProcessing.renderer ?? "pipeline";
|
|
1868
|
-
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);
|
|
1869
1910
|
}
|
|
1870
|
-
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;
|
|
1871
1912
|
}
|
|
1872
1913
|
async _loadSceneFile(e) {
|
|
1873
1914
|
let t = this._getScenePath();
|
|
@@ -1898,10 +1939,10 @@ var J = class {
|
|
|
1898
1939
|
}
|
|
1899
1940
|
e.environmentTexture && e.createDefaultSkybox(e.environmentTexture, !0, t.skyboxSize ?? 1e3, 0, !1);
|
|
1900
1941
|
} else {
|
|
1901
|
-
let n = t.skyboxSize ?? 1e3, r =
|
|
1942
|
+
let n = t.skyboxSize ?? 1e3, r = b.CreateSphere("skybox", {
|
|
1902
1943
|
diameter: n,
|
|
1903
1944
|
segments: 32
|
|
1904
|
-
}, e), i = new
|
|
1945
|
+
}, e), i = new O("skybox-mat", e);
|
|
1905
1946
|
i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new ae(t.skybox, e), r.material = i, r.infiniteDistance = !0;
|
|
1906
1947
|
}
|
|
1907
1948
|
this._log.debug(`Skybox set from: ${t.skybox}`);
|
|
@@ -1938,10 +1979,10 @@ var J = class {
|
|
|
1938
1979
|
}
|
|
1939
1980
|
}
|
|
1940
1981
|
_createCamera(e, t, r) {
|
|
1941
|
-
let i = t.position ?
|
|
1982
|
+
let i = t.position ? J(t.position) : A.Zero(), a;
|
|
1942
1983
|
switch (t.type) {
|
|
1943
1984
|
case "arcRotate": {
|
|
1944
|
-
let i = t.target ?
|
|
1985
|
+
let i = t.target ? J(t.target) : A.Zero();
|
|
1945
1986
|
a = new n(e, t.alpha ?? Math.PI / 2, t.beta ?? Math.PI / 3, t.radius ?? 10, i, r);
|
|
1946
1987
|
break;
|
|
1947
1988
|
}
|
|
@@ -1949,9 +1990,9 @@ var J = class {
|
|
|
1949
1990
|
a = new oe(e, i, r);
|
|
1950
1991
|
break;
|
|
1951
1992
|
case "geospatial": {
|
|
1952
|
-
if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e,
|
|
1993
|
+
if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e, A.Zero(), r);
|
|
1953
1994
|
let n = new le(e, r, { planetRadius: t.planetRadius });
|
|
1954
|
-
t.center && (n.center =
|
|
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;
|
|
1955
1996
|
break;
|
|
1956
1997
|
}
|
|
1957
1998
|
default:
|
|
@@ -1961,7 +2002,7 @@ var J = class {
|
|
|
1961
2002
|
return this._applyCameraConfig(a, t), a;
|
|
1962
2003
|
}
|
|
1963
2004
|
_applyCameraConfig(e, t) {
|
|
1964
|
-
t.fov !== void 0 && (e.fov = t.fov), t.position && (e.position =
|
|
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));
|
|
1965
2006
|
}
|
|
1966
2007
|
_processLights(e) {
|
|
1967
2008
|
let t = this._config.lights;
|
|
@@ -1971,7 +2012,7 @@ var J = class {
|
|
|
1971
2012
|
}
|
|
1972
2013
|
}
|
|
1973
2014
|
_createLight(e, t, n) {
|
|
1974
|
-
let r = t.direction ?
|
|
2015
|
+
let r = t.direction ? J(t.direction) : new A(0, -1, 0), i = t.position ? J(t.position) : A.Zero();
|
|
1975
2016
|
switch (t.type) {
|
|
1976
2017
|
case "hemispheric": {
|
|
1977
2018
|
let i = new m(e, r, n);
|
|
@@ -1989,15 +2030,15 @@ var J = class {
|
|
|
1989
2030
|
break;
|
|
1990
2031
|
}
|
|
1991
2032
|
case "spot": {
|
|
1992
|
-
let a = new
|
|
2033
|
+
let a = new D(e, i, r, t.angle ?? Math.PI / 3, t.exponent ?? 2, n);
|
|
1993
2034
|
this._applyLightConfig(a, t);
|
|
1994
2035
|
break;
|
|
1995
2036
|
}
|
|
1996
2037
|
case "rectarea": {
|
|
1997
|
-
let a = new
|
|
2038
|
+
let a = new T(e, i, t.width ?? 1, t.height ?? 1, n);
|
|
1998
2039
|
if (this._applyLightConfig(a, t), t.direction) {
|
|
1999
|
-
let t = new
|
|
2000
|
-
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));
|
|
2001
2042
|
}
|
|
2002
2043
|
break;
|
|
2003
2044
|
}
|
|
@@ -2017,17 +2058,14 @@ var J = class {
|
|
|
2017
2058
|
for (let t of n) e.removeLight(t);
|
|
2018
2059
|
let r = new ue("sage-clustered", n, e);
|
|
2019
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`);
|
|
2020
|
-
for (let t of e.materials) t instanceof
|
|
2021
|
-
}
|
|
2022
|
-
_toVector3(e) {
|
|
2023
|
-
return new O(e.x, e.y, e.z);
|
|
2061
|
+
for (let t of e.materials) t instanceof ee && (t.useGLTFLightFalloff = !0);
|
|
2024
2062
|
}
|
|
2025
2063
|
_toColor3(e) {
|
|
2026
2064
|
return new r(e.r, e.g, e.b);
|
|
2027
2065
|
}
|
|
2028
2066
|
async _enablePhysics(e) {
|
|
2029
|
-
let t = this._config.physics, n = new
|
|
2030
|
-
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));
|
|
2031
2069
|
let r = this.gameEngine.largeWorldRendering ? 1e5 : void 0;
|
|
2032
2070
|
this._log.debug(`Enabling physics with gravity: ${n.toString()}`), await this.gameEngine.engines.sceneEngine.enablePhysics(e, n, r);
|
|
2033
2071
|
}
|
|
@@ -2048,16 +2086,22 @@ var J = class {
|
|
|
2048
2086
|
return t ? { ...t } : e.metadata;
|
|
2049
2087
|
}
|
|
2050
2088
|
async _processNodeMetadata(e) {
|
|
2051
|
-
"spawn" in e.metadata
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
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({
|
|
2058
2100
|
type: e.metadata.entity,
|
|
2059
2101
|
node: e
|
|
2060
|
-
});
|
|
2102
|
+
}), await this._runPropertyHandlers(e);
|
|
2103
|
+
}
|
|
2104
|
+
async _runPropertyHandlers(e) {
|
|
2061
2105
|
for (let [t, n] of this.propertyHandlers) if (t in e.metadata) try {
|
|
2062
2106
|
await n(e, e.metadata[t], this, this.gameEngine);
|
|
2063
2107
|
} catch (n) {
|
|
@@ -2081,9 +2125,9 @@ var J = class {
|
|
|
2081
2125
|
async _spawnEntity(e, t) {
|
|
2082
2126
|
let n = {
|
|
2083
2127
|
...e.config,
|
|
2084
|
-
position:
|
|
2085
|
-
rotation:
|
|
2086
|
-
scaling:
|
|
2128
|
+
position: q(t.position),
|
|
2129
|
+
rotation: Ne(t.rotation),
|
|
2130
|
+
scaling: q(t.scaling)
|
|
2087
2131
|
}, r = await this.gameEngine.managers.entityManager.createEntity(e.entity, {
|
|
2088
2132
|
name: e.name,
|
|
2089
2133
|
tags: e.tags,
|
|
@@ -2091,23 +2135,14 @@ var J = class {
|
|
|
2091
2135
|
});
|
|
2092
2136
|
return await this._createEntityMesh(r, t), r;
|
|
2093
2137
|
}
|
|
2094
|
-
_vectorToObject(e) {
|
|
2095
|
-
return {
|
|
2096
|
-
x: e.x,
|
|
2097
|
-
y: e.y,
|
|
2098
|
-
z: e.z
|
|
2099
|
-
};
|
|
2100
|
-
}
|
|
2101
2138
|
async _createEntityMesh(e, t) {
|
|
2102
2139
|
if (!this._scene) return;
|
|
2103
2140
|
let n = this.gameEngine.managers.entityManager.getDefinition(e.type);
|
|
2104
2141
|
if (!n?.mesh) return;
|
|
2105
|
-
let r = n.mesh, i = this._scene, a = new
|
|
2106
|
-
a.position.copyFrom(t.position), a.rotation.copyFrom(t.rotation);
|
|
2107
|
-
let o;
|
|
2142
|
+
let r = n.mesh, i = this._scene, a = new k(`entity-${e.id}`, i), o;
|
|
2108
2143
|
switch (r.source) {
|
|
2109
2144
|
case "box":
|
|
2110
|
-
o = [
|
|
2145
|
+
o = [b.CreateBox(`${e.type}-mesh`, {
|
|
2111
2146
|
size: r.params?.size ?? 1,
|
|
2112
2147
|
width: r.params?.width,
|
|
2113
2148
|
height: r.params?.height,
|
|
@@ -2115,19 +2150,19 @@ var J = class {
|
|
|
2115
2150
|
}, i)];
|
|
2116
2151
|
break;
|
|
2117
2152
|
case "sphere":
|
|
2118
|
-
o = [
|
|
2153
|
+
o = [b.CreateSphere(`${e.type}-mesh`, {
|
|
2119
2154
|
diameter: r.params?.diameter ?? 1,
|
|
2120
2155
|
segments: r.params?.segments ?? 16
|
|
2121
2156
|
}, i)];
|
|
2122
2157
|
break;
|
|
2123
2158
|
case "capsule":
|
|
2124
|
-
o = [
|
|
2159
|
+
o = [b.CreateCapsule(`${e.type}-mesh`, {
|
|
2125
2160
|
height: r.params?.height ?? 1.8,
|
|
2126
2161
|
radius: r.params?.radius ?? .4
|
|
2127
2162
|
}, i)];
|
|
2128
2163
|
break;
|
|
2129
2164
|
case "cylinder":
|
|
2130
|
-
o = [
|
|
2165
|
+
o = [b.CreateCylinder(`${e.type}-mesh`, {
|
|
2131
2166
|
height: r.params?.height ?? 1,
|
|
2132
2167
|
diameter: r.params?.diameter ?? 1
|
|
2133
2168
|
}, i)];
|
|
@@ -2144,20 +2179,28 @@ var J = class {
|
|
|
2144
2179
|
}
|
|
2145
2180
|
}
|
|
2146
2181
|
for (let e of o) e.parent ||= a;
|
|
2147
|
-
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));
|
|
2148
2183
|
let s = r.material;
|
|
2149
2184
|
if (s?.color) {
|
|
2150
2185
|
let t = s.color;
|
|
2151
2186
|
if (s.type === "pbr") {
|
|
2152
|
-
let n = new
|
|
2187
|
+
let n = new ee(`${e.type}-material`, i);
|
|
2153
2188
|
n.albedoColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive)), n.metallic = s.metallic ?? 0, n.roughness = s.roughness ?? 1;
|
|
2154
2189
|
for (let e of o) e.material = n;
|
|
2155
2190
|
} else {
|
|
2156
|
-
let n = new
|
|
2191
|
+
let n = new O(`${e.type}-material`, i);
|
|
2157
2192
|
n.diffuseColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive));
|
|
2158
2193
|
for (let e of o) e.material = n;
|
|
2159
2194
|
}
|
|
2160
2195
|
}
|
|
2196
|
+
let c = a.getDescendants(!1).filter((e) => e instanceof k);
|
|
2197
|
+
for (let e of c) {
|
|
2198
|
+
let t = this._getNormalizedMetadata(e);
|
|
2199
|
+
t && Object.keys(t).length > 0 && (e.metadata = {
|
|
2200
|
+
...e.metadata,
|
|
2201
|
+
...t
|
|
2202
|
+
}, await this._runPropertyHandlers(e));
|
|
2203
|
+
}
|
|
2161
2204
|
this.gameEngine.managers.entityManager.attachToNode(e, a);
|
|
2162
2205
|
}
|
|
2163
2206
|
async _processEntityNodes() {
|
|
@@ -2168,7 +2211,7 @@ var J = class {
|
|
|
2168
2211
|
try {
|
|
2169
2212
|
let n = {
|
|
2170
2213
|
...t?.config,
|
|
2171
|
-
position:
|
|
2214
|
+
position: q(e.node.position)
|
|
2172
2215
|
}, r = await this.gameEngine.managers.entityManager.createEntity(e.type, {
|
|
2173
2216
|
name: t?.name ?? e.node.name,
|
|
2174
2217
|
tags: t?.tags,
|
|
@@ -2199,7 +2242,7 @@ var J = class {
|
|
|
2199
2242
|
}
|
|
2200
2243
|
}
|
|
2201
2244
|
async onDeactivate() {
|
|
2202
|
-
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());
|
|
2203
2246
|
}
|
|
2204
2247
|
async onActivate() {
|
|
2205
2248
|
for (let e of this._playingSoundsBeforeDeactivate) {
|
|
@@ -2220,7 +2263,7 @@ var J = class {
|
|
|
2220
2263
|
for (let e of this._levelSounds.values()) e.dispose();
|
|
2221
2264
|
this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.$dispose();
|
|
2222
2265
|
}
|
|
2223
|
-
},
|
|
2266
|
+
}, Be = class {
|
|
2224
2267
|
_eventBus;
|
|
2225
2268
|
_gameEngine = null;
|
|
2226
2269
|
_log;
|
|
@@ -2238,7 +2281,7 @@ var J = class {
|
|
|
2238
2281
|
return this._propertyHandlers;
|
|
2239
2282
|
}
|
|
2240
2283
|
constructor(e, t) {
|
|
2241
|
-
this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new
|
|
2284
|
+
this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new M("LevelManager"), this._eventUnsubscribers.push(this._eventBus.subscribe("level:progress", (e) => {
|
|
2242
2285
|
this._handleProgress(e.payload);
|
|
2243
2286
|
})), this._eventUnsubscribers.push(this._eventBus.subscribe("level:complete", (e) => {
|
|
2244
2287
|
this._handleComplete(e.payload);
|
|
@@ -2273,7 +2316,7 @@ var J = class {
|
|
|
2273
2316
|
if (!n) throw Error(`Level class '${e.class}' is not registered.`);
|
|
2274
2317
|
return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
|
|
2275
2318
|
}
|
|
2276
|
-
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);
|
|
2277
2320
|
}
|
|
2278
2321
|
registerLevelConfig(e) {
|
|
2279
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}`);
|
|
@@ -2359,7 +2402,7 @@ var J = class {
|
|
|
2359
2402
|
for (let e of this._loadedLevels.values()) await e.$dispose();
|
|
2360
2403
|
this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
|
|
2361
2404
|
}
|
|
2362
|
-
},
|
|
2405
|
+
}, Ve = class {
|
|
2363
2406
|
_audioEngine;
|
|
2364
2407
|
_channels = /* @__PURE__ */ new Map();
|
|
2365
2408
|
_masterMuted = !1;
|
|
@@ -2430,14 +2473,14 @@ var J = class {
|
|
|
2430
2473
|
getChannels() {
|
|
2431
2474
|
return Array.from(this._channels.keys());
|
|
2432
2475
|
}
|
|
2433
|
-
},
|
|
2476
|
+
}, He = class {
|
|
2434
2477
|
_entityManager;
|
|
2435
2478
|
_levelManager;
|
|
2436
2479
|
_log;
|
|
2437
2480
|
_beforeSerializeHooks = [];
|
|
2438
2481
|
_afterDeserializeHooks = [];
|
|
2439
2482
|
constructor(e, t, n) {
|
|
2440
|
-
this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new
|
|
2483
|
+
this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new M("SaveManager"), this._log.info("SaveManager initialized");
|
|
2441
2484
|
}
|
|
2442
2485
|
onBeforeSerialize(e) {
|
|
2443
2486
|
this._beforeSerializeHooks.push(e);
|
|
@@ -2520,7 +2563,7 @@ var J = class {
|
|
|
2520
2563
|
async $teardown() {
|
|
2521
2564
|
this._beforeSerializeHooks = [], this._afterDeserializeHooks = [], this._log.info("SaveManager torn down");
|
|
2522
2565
|
}
|
|
2523
|
-
},
|
|
2566
|
+
}, Ue = class {
|
|
2524
2567
|
_keyboardDevice;
|
|
2525
2568
|
_keysState = {};
|
|
2526
2569
|
_onDeviceConnected;
|
|
@@ -2585,7 +2628,7 @@ var J = class {
|
|
|
2585
2628
|
_notifyInputChanged(e) {
|
|
2586
2629
|
this._onInputChanged && this._onInputChanged(this._keyboardDevice, e);
|
|
2587
2630
|
}
|
|
2588
|
-
},
|
|
2631
|
+
}, We = class {
|
|
2589
2632
|
_targetElement;
|
|
2590
2633
|
_mouseDevice;
|
|
2591
2634
|
_buttonState = {};
|
|
@@ -2704,7 +2747,7 @@ var J = class {
|
|
|
2704
2747
|
_notifyInputChanged(e) {
|
|
2705
2748
|
this._onInputChanged && this._onInputChanged(this._mouseDevice, e);
|
|
2706
2749
|
}
|
|
2707
|
-
},
|
|
2750
|
+
}, Ge = class {
|
|
2708
2751
|
_gamepadDevices = {};
|
|
2709
2752
|
_buttonStates = {};
|
|
2710
2753
|
_axesStates = {};
|
|
@@ -2838,14 +2881,14 @@ var J = class {
|
|
|
2838
2881
|
_notifyInputChanged(e, t) {
|
|
2839
2882
|
this._onInputChanged && this._onInputChanged(e, t);
|
|
2840
2883
|
}
|
|
2841
|
-
},
|
|
2884
|
+
}, Ke = class {
|
|
2842
2885
|
_eventBus;
|
|
2843
2886
|
_keyboardRA;
|
|
2844
2887
|
_mouseRA;
|
|
2845
2888
|
_gamepadRA;
|
|
2846
2889
|
_log;
|
|
2847
2890
|
constructor(e, t, n) {
|
|
2848
|
-
this._eventBus = e, this._log = n?.getLogger("UserInputManager") || 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");
|
|
2849
2892
|
}
|
|
2850
2893
|
_publishDeviceConnected(e) {
|
|
2851
2894
|
this._log.debug(`Device connected: ${e.id} (${e.name})`), this._eventBus.publish({
|
|
@@ -2898,18 +2941,18 @@ var J = class {
|
|
|
2898
2941
|
};
|
|
2899
2942
|
//#endregion
|
|
2900
2943
|
//#region src/utils/graphics.ts
|
|
2901
|
-
async function
|
|
2944
|
+
async function qe(e, t) {
|
|
2902
2945
|
let n = new se(e, t);
|
|
2903
2946
|
return await n.initAsync(), n;
|
|
2904
2947
|
}
|
|
2905
2948
|
function Y(e, t) {
|
|
2906
2949
|
return new l(e, t.antialias, t.options, t.adaptToDeviceRatio);
|
|
2907
2950
|
}
|
|
2908
|
-
function
|
|
2909
|
-
return new
|
|
2951
|
+
function Je(e) {
|
|
2952
|
+
return new x(e);
|
|
2910
2953
|
}
|
|
2911
|
-
async function
|
|
2912
|
-
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);
|
|
2913
2956
|
if (n) if ("options" in t) {
|
|
2914
2957
|
let e = t;
|
|
2915
2958
|
t = {
|
|
@@ -2925,14 +2968,14 @@ async function Ve(e, t, n = !1) {
|
|
|
2925
2968
|
};
|
|
2926
2969
|
let r = t.engine || "auto";
|
|
2927
2970
|
if (r === "webgpu") if (V()) try {
|
|
2928
|
-
return console.debug("Using forced WebGPU engine"), await
|
|
2971
|
+
return console.debug("Using forced WebGPU engine"), await qe(e, t);
|
|
2929
2972
|
} catch (e) {
|
|
2930
2973
|
throw console.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
|
|
2931
2974
|
}
|
|
2932
2975
|
else throw Error("WebGPU was forced but is not available in this browser.");
|
|
2933
2976
|
if (r === "webgl") return console.debug("Using forced WebGL engine"), Y(e, t);
|
|
2934
2977
|
if (V()) try {
|
|
2935
|
-
return console.debug("Using WebGPU"),
|
|
2978
|
+
return console.debug("Using WebGPU"), qe(e, t).catch((n) => (console.warn("WebGPU initialization failed, falling back to WebGL:", n), Y(e, t)));
|
|
2936
2979
|
} catch (e) {
|
|
2937
2980
|
console.warn("WebGPU initialization failed, falling back to WebGL:", e);
|
|
2938
2981
|
}
|
|
@@ -2941,15 +2984,15 @@ async function Ve(e, t, n = !1) {
|
|
|
2941
2984
|
}
|
|
2942
2985
|
//#endregion
|
|
2943
2986
|
//#region src/utils/physics.ts
|
|
2944
|
-
async function
|
|
2987
|
+
async function Xe() {
|
|
2945
2988
|
return await de();
|
|
2946
2989
|
}
|
|
2947
|
-
function
|
|
2990
|
+
function Ze(e) {
|
|
2948
2991
|
return new p(!0, e);
|
|
2949
2992
|
}
|
|
2950
2993
|
//#endregion
|
|
2951
2994
|
//#region src/utils/raycast.ts
|
|
2952
|
-
var
|
|
2995
|
+
var Qe = class {
|
|
2953
2996
|
_entityManager;
|
|
2954
2997
|
constructor(e) {
|
|
2955
2998
|
this._entityManager = e;
|
|
@@ -3015,7 +3058,7 @@ var We = class {
|
|
|
3015
3058
|
pickingInfo: e
|
|
3016
3059
|
};
|
|
3017
3060
|
}
|
|
3018
|
-
},
|
|
3061
|
+
}, $e = class {
|
|
3019
3062
|
_nextId = 0;
|
|
3020
3063
|
_delays = [];
|
|
3021
3064
|
_intervals = [];
|
|
@@ -3070,21 +3113,21 @@ var We = class {
|
|
|
3070
3113
|
for (let t of this._intervals) for (t.elapsed += e; t.elapsed >= t.periodMs;) t.callback(), t.elapsed -= t.periodMs;
|
|
3071
3114
|
for (let t of this._cooldowns) t.remaining > 0 && (t.remaining = Math.max(0, t.remaining - e));
|
|
3072
3115
|
}
|
|
3073
|
-
},
|
|
3116
|
+
}, et = [
|
|
3074
3117
|
"trace",
|
|
3075
3118
|
"debug",
|
|
3076
3119
|
"info",
|
|
3077
3120
|
"warn",
|
|
3078
3121
|
"error",
|
|
3079
3122
|
"none"
|
|
3080
|
-
],
|
|
3123
|
+
], tt = class extends G {
|
|
3081
3124
|
name = "sound";
|
|
3082
3125
|
eventSubscriptions = [];
|
|
3083
3126
|
_sounds = /* @__PURE__ */ new Map();
|
|
3084
3127
|
_initialized = !1;
|
|
3085
3128
|
_audioManager = null;
|
|
3086
3129
|
_node = null;
|
|
3087
|
-
_log = new
|
|
3130
|
+
_log = new M("SoundBehavior");
|
|
3088
3131
|
onNodeAttached(e, t) {
|
|
3089
3132
|
if (this._initialized) return;
|
|
3090
3133
|
if (this._node = e, this._initialized = !0, this._log = t.logger.getLogger("SoundBehavior"), t.managers.audioManager) this._audioManager = t.managers.audioManager;
|
|
@@ -3146,7 +3189,7 @@ var We = class {
|
|
|
3146
3189
|
} else for (let t of this._sounds.values()) t.volume = e;
|
|
3147
3190
|
}
|
|
3148
3191
|
isPlaying(e) {
|
|
3149
|
-
return this._getSound(e)?.state ===
|
|
3192
|
+
return this._getSound(e)?.state === E.Started;
|
|
3150
3193
|
}
|
|
3151
3194
|
getSoundNames() {
|
|
3152
3195
|
return Array.from(this._sounds.keys());
|
|
@@ -3222,7 +3265,7 @@ var We = class {
|
|
|
3222
3265
|
}
|
|
3223
3266
|
});
|
|
3224
3267
|
}
|
|
3225
|
-
},
|
|
3268
|
+
}, nt = class extends G {
|
|
3226
3269
|
name = "stateMachine";
|
|
3227
3270
|
eventSubscriptions = [];
|
|
3228
3271
|
stateMachine;
|
|
@@ -3241,7 +3284,7 @@ var We = class {
|
|
|
3241
3284
|
}
|
|
3242
3285
|
static create(e) {
|
|
3243
3286
|
let { initialState: t, stateKey: n, transitions: r, wildcardTransitions: i } = e;
|
|
3244
|
-
class a extends
|
|
3287
|
+
class a extends nt {
|
|
3245
3288
|
constructor() {
|
|
3246
3289
|
super(), this.stateKey = n, this.stateMachine = new X(t);
|
|
3247
3290
|
for (let e of r) this.stateMachine.addTransition(e.from, e.to, e.guard);
|
|
@@ -3250,58 +3293,55 @@ var We = class {
|
|
|
3250
3293
|
}
|
|
3251
3294
|
return a;
|
|
3252
3295
|
}
|
|
3253
|
-
}, Z = new
|
|
3296
|
+
}, Z = new M("ColliderHandler");
|
|
3254
3297
|
function Q(e, t, n) {
|
|
3255
3298
|
let r = e.getScene();
|
|
3256
|
-
new
|
|
3299
|
+
new S(e, t, { mass: n }, r);
|
|
3257
3300
|
}
|
|
3258
|
-
function
|
|
3301
|
+
function rt(e, t) {
|
|
3259
3302
|
let n = e.getChildMeshes().find((e) => e.metadata?.collider_mesh === !0);
|
|
3260
|
-
n instanceof
|
|
3303
|
+
n instanceof y ? (n.isVisible = !1, Q(n, C.MESH, t)) : Q(e, C.MESH, t);
|
|
3261
3304
|
}
|
|
3262
|
-
function
|
|
3263
|
-
|
|
3264
|
-
let
|
|
3265
|
-
if (Z.debug(`Processing collider: ${
|
|
3266
|
-
if (!(
|
|
3267
|
-
Z.warn(`Skipping collider for ${
|
|
3305
|
+
function it(t) {
|
|
3306
|
+
t.registerPropertyHandler("collider", (t, n, r, i) => {
|
|
3307
|
+
let a = n;
|
|
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") {
|
|
3310
|
+
Z.warn(`Skipping mesh collider for ${t.name}: not a Mesh instance`);
|
|
3268
3311
|
return;
|
|
3269
3312
|
}
|
|
3270
|
-
let
|
|
3271
|
-
switch (
|
|
3313
|
+
let o = t.metadata?.collider_mass ?? 0;
|
|
3314
|
+
switch (a) {
|
|
3272
3315
|
case "box":
|
|
3273
|
-
Q(
|
|
3316
|
+
Q(t, C.BOX, o);
|
|
3274
3317
|
break;
|
|
3275
3318
|
case "sphere":
|
|
3276
|
-
Q(
|
|
3319
|
+
Q(t, C.SPHERE, o);
|
|
3277
3320
|
break;
|
|
3278
3321
|
case "mesh":
|
|
3279
|
-
|
|
3322
|
+
rt(t, o);
|
|
3280
3323
|
break;
|
|
3281
3324
|
case "none":
|
|
3282
|
-
e.checkCollisions = !1;
|
|
3325
|
+
t instanceof e && (t.checkCollisions = !1);
|
|
3283
3326
|
break;
|
|
3284
|
-
default: Z.warn(`Unknown collider type: ${
|
|
3285
|
-
}
|
|
3286
|
-
if (e.metadata?.collider_kinematic) {
|
|
3287
|
-
let t = e;
|
|
3288
|
-
t.physicsBody && (t.physicsBody.disablePreStep = !1);
|
|
3327
|
+
default: Z.warn(`Unknown collider type: ${a}`);
|
|
3289
3328
|
}
|
|
3329
|
+
t.metadata?.collider_kinematic && t instanceof e && t.physicsBody && (t.physicsBody.disablePreStep = !1);
|
|
3290
3330
|
});
|
|
3291
3331
|
}
|
|
3292
3332
|
//#endregion
|
|
3293
3333
|
//#region src/handlers/lod.ts
|
|
3294
|
-
var
|
|
3295
|
-
function
|
|
3334
|
+
var at = new M("LodHandler");
|
|
3335
|
+
function ot(e) {
|
|
3296
3336
|
return e.split(",").map((e) => parseFloat(e.trim())).filter((e) => !isNaN(e));
|
|
3297
3337
|
}
|
|
3298
|
-
function
|
|
3338
|
+
function st(e) {
|
|
3299
3339
|
e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
|
|
3300
3340
|
let i = t;
|
|
3301
|
-
if (!(e instanceof
|
|
3302
|
-
let a =
|
|
3341
|
+
if (!(e instanceof y)) return;
|
|
3342
|
+
let a = ot(i);
|
|
3303
3343
|
if (a.length === 0) {
|
|
3304
|
-
|
|
3344
|
+
at.warn(`Invalid lod_distances value: ${i}`);
|
|
3305
3345
|
return;
|
|
3306
3346
|
}
|
|
3307
3347
|
let o = e.getChildMeshes(!0), s = Math.min(a.length, o.length);
|
|
@@ -3314,12 +3354,12 @@ function $e(e) {
|
|
|
3314
3354
|
//#region src/handlers/occluder.ts
|
|
3315
3355
|
function $(e) {
|
|
3316
3356
|
e.registerPropertyHandler("occluder", (e, t, n, r) => {
|
|
3317
|
-
t && e instanceof
|
|
3357
|
+
t && e instanceof y && (e.isOccluder = !0, e.isVisible = !1);
|
|
3318
3358
|
});
|
|
3319
3359
|
}
|
|
3320
3360
|
//#endregion
|
|
3321
3361
|
//#region src/utils/metadata.ts
|
|
3322
|
-
function
|
|
3362
|
+
function ct(e, t) {
|
|
3323
3363
|
let n = {}, r = `${t}_`;
|
|
3324
3364
|
for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
|
|
3325
3365
|
let e = t.slice(r.length);
|
|
@@ -3329,14 +3369,14 @@ function et(e, t) {
|
|
|
3329
3369
|
}
|
|
3330
3370
|
//#endregion
|
|
3331
3371
|
//#region src/handlers/sound.ts
|
|
3332
|
-
var
|
|
3333
|
-
function
|
|
3372
|
+
var lt = new M("SoundHandler");
|
|
3373
|
+
function ut(e) {
|
|
3334
3374
|
e.registerPropertyHandler("sound", (e, t, n, r) => {
|
|
3335
3375
|
let i = t;
|
|
3336
3376
|
if (!n.scene) throw Error("Scene not available for sound handler");
|
|
3337
|
-
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;
|
|
3338
3378
|
if (!f) {
|
|
3339
|
-
|
|
3379
|
+
lt.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
|
|
3340
3380
|
return;
|
|
3341
3381
|
}
|
|
3342
3382
|
f.createSound(`${e.name}_sound`, i, d, {
|
|
@@ -3349,13 +3389,13 @@ function nt(e) {
|
|
|
3349
3389
|
}).then((t) => {
|
|
3350
3390
|
c && t.spatial.attach(e);
|
|
3351
3391
|
}).catch((t) => {
|
|
3352
|
-
|
|
3392
|
+
lt.error(`Failed to create sound for node "${e.name}": ${t}`);
|
|
3353
3393
|
});
|
|
3354
3394
|
});
|
|
3355
3395
|
}
|
|
3356
3396
|
//#endregion
|
|
3357
3397
|
//#region src/handlers/trigger.ts
|
|
3358
|
-
function
|
|
3398
|
+
function dt(e, n, r, i, a) {
|
|
3359
3399
|
let o = a === "enter" ? t.OnIntersectionEnterTrigger : t.OnIntersectionExitTrigger, s = `trigger:${a}`;
|
|
3360
3400
|
e.registerAction(new u({
|
|
3361
3401
|
trigger: o,
|
|
@@ -3370,10 +3410,10 @@ function rt(e, n, r, i, a) {
|
|
|
3370
3410
|
});
|
|
3371
3411
|
}));
|
|
3372
3412
|
}
|
|
3373
|
-
function
|
|
3374
|
-
|
|
3413
|
+
function ft(e, t, n, r) {
|
|
3414
|
+
dt(e, t, n, r, "enter"), dt(e, t, n, r, "exit");
|
|
3375
3415
|
}
|
|
3376
|
-
function
|
|
3416
|
+
function pt(n) {
|
|
3377
3417
|
n.registerPropertyHandler("trigger", (n, r, i, a) => {
|
|
3378
3418
|
let o = r, s = i.scene;
|
|
3379
3419
|
if (!s) throw Error("Scene not available for trigger handler");
|
|
@@ -3382,9 +3422,9 @@ function at(n) {
|
|
|
3382
3422
|
n.isVisible = !1, n.checkCollisions = !0;
|
|
3383
3423
|
let l = n.actionManager ?? new t(s);
|
|
3384
3424
|
n.actionManager = l;
|
|
3385
|
-
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);
|
|
3386
3426
|
let u = s.onNewMeshAddedObservable.add((e) => {
|
|
3387
|
-
e !== n && !e.metadata?.trigger &&
|
|
3427
|
+
e !== n && !e.metadata?.trigger && ft(l, o, c, e);
|
|
3388
3428
|
});
|
|
3389
3429
|
n.onDisposeObservable.add(() => {
|
|
3390
3430
|
s.onNewMeshAddedObservable.remove(u);
|
|
@@ -3393,7 +3433,7 @@ function at(n) {
|
|
|
3393
3433
|
}
|
|
3394
3434
|
//#endregion
|
|
3395
3435
|
//#region src/handlers/visible.ts
|
|
3396
|
-
function
|
|
3436
|
+
function mt(t) {
|
|
3397
3437
|
t.registerPropertyHandler("visible", (t, n, r, i) => {
|
|
3398
3438
|
if (!(t instanceof e)) return;
|
|
3399
3439
|
let a = !0;
|
|
@@ -3402,39 +3442,39 @@ function ot(t) {
|
|
|
3402
3442
|
}
|
|
3403
3443
|
//#endregion
|
|
3404
3444
|
//#region src/handlers/index.ts
|
|
3405
|
-
function
|
|
3406
|
-
|
|
3445
|
+
function ht(e) {
|
|
3446
|
+
it(e), st(e), $(e), ut(e), pt(e), mt(e);
|
|
3407
3447
|
}
|
|
3408
3448
|
//#endregion
|
|
3409
3449
|
//#region src/sage.ts
|
|
3410
|
-
async function
|
|
3411
|
-
let r = new
|
|
3412
|
-
i.info(`Initializing SAGE Game Engine v${
|
|
3413
|
-
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, {
|
|
3414
3454
|
antialias: !0,
|
|
3415
3455
|
adaptToDeviceRatio: !0,
|
|
3416
3456
|
...n.renderOptions
|
|
3417
3457
|
}, n.largeWorldRendering ?? !1);
|
|
3418
3458
|
i.debug("Creating physics engine...");
|
|
3419
|
-
let o = await
|
|
3459
|
+
let o = await Xe(), s = Ze(o);
|
|
3420
3460
|
i.debug("Creating event bus...");
|
|
3421
|
-
let c = new
|
|
3461
|
+
let c = new ge(r);
|
|
3422
3462
|
i.debug("Creating scene engine...");
|
|
3423
3463
|
let l = new P(e, a, o, r);
|
|
3424
3464
|
i.debug("Creating managers...");
|
|
3425
|
-
let u = new F(c, l, r), d = 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);
|
|
3426
3466
|
i.debug("Creating raycast helper...");
|
|
3427
|
-
let
|
|
3467
|
+
let _ = new Qe(p);
|
|
3428
3468
|
i.debug("Creating game timer...");
|
|
3429
|
-
let
|
|
3430
|
-
g.registerFrameCallback((e) =>
|
|
3431
|
-
let
|
|
3432
|
-
n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."),
|
|
3469
|
+
let v = new $e();
|
|
3470
|
+
g.registerFrameCallback((e) => v.tick(e * 1e3));
|
|
3471
|
+
let y, b;
|
|
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...");
|
|
3433
3473
|
for (let e of t) p.registerEntityDefinition(e);
|
|
3434
3474
|
if (i.debug("Registering default input bindings..."), n.bindings) for (let e of n.bindings) f.registerBinding(e);
|
|
3435
|
-
let
|
|
3475
|
+
let x = new fe(e, a, s, c, r, _, v, {
|
|
3436
3476
|
sceneEngine: l,
|
|
3437
|
-
audioEngine:
|
|
3477
|
+
audioEngine: y
|
|
3438
3478
|
}, {
|
|
3439
3479
|
assetManager: u,
|
|
3440
3480
|
bindingManager: f,
|
|
@@ -3443,11 +3483,11 @@ async function ct(e, t, n = {}) {
|
|
|
3443
3483
|
inputManager: d,
|
|
3444
3484
|
levelManager: m,
|
|
3445
3485
|
saveManager: h,
|
|
3446
|
-
audioManager:
|
|
3486
|
+
audioManager: b
|
|
3447
3487
|
}, n.largeWorldRendering ?? !1);
|
|
3448
|
-
return p.$setGameEngine(
|
|
3488
|
+
return p.$setGameEngine(x), m.$setGameEngine(x), x;
|
|
3449
3489
|
}
|
|
3450
3490
|
//#endregion
|
|
3451
|
-
export { F as AssetManager, N as AudioEngine,
|
|
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 };
|
|
3452
3492
|
|
|
3453
3493
|
//# sourceMappingURL=sage.es.js.map
|