@skewedaspect/sage 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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 ee, Mesh as _, MeshBuilder as v, NullEngine as y, PBRMaterial as b, PhysicsAggregate as x, PhysicsShapeType as S, PointLight as te, RectAreaLight as C, SSAO2RenderingPipeline as ne, Scene as re, SelectionOutlineLayer as ie, SoundState as w, SpotLight as T, StandardMaterial as E, Texture as ae, TransformNode as D, UniversalCamera as oe, Vector3 as O, 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";
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 _, Mesh as v, MeshBuilder as y, NullEngine as b, PBRMaterial as x, PhysicsAggregate as ee, PhysicsShapeType as S, PointLight as C, Quaternion as te, RectAreaLight as w, SSAO2RenderingPipeline as ne, Scene as re, SelectionOutlineLayer as ie, SoundState as ae, SpotLight as oe, StandardMaterial as se, Texture as ce, TransformNode as le, UniversalCamera as ue, Vector3 as T, WebGPUEngine as de } from "@babylonjs/core";
2
+ import { registerBuiltInLoaders as fe } from "@babylonjs/loaders/dynamic";
3
+ import { GeospatialCamera as E } from "@babylonjs/core/Cameras/geospatialCamera";
4
+ import { ClusteredLightContainer as D } from "@babylonjs/core/Lights/Clustered/clusteredLightContainer";
5
+ import pe from "@babylonjs/havok";
6
6
  //#region src/utils/version.ts
7
- var k = "0.9.0", fe = class {
7
+ var O = "0.9.1", k = 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: ${k})...`), this._beforeStartHook && (this._log.debug("Executing beforeStart hook..."), await this._beforeStartHook(this)), await this.managers.gameManager.start(), this._log.info("Game engine started successfully"), this._onStartHook && (this._log.debug("Executing onStart hook..."), await this._onStartHook(this)), this.started = !0);
45
+ this.started ? this._log.warn("Game engine is already started. Skipping start.") : (this._log.info(`Starting SkewedAspect Game Engine (Version: ${O})...`), 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: ${k})...`);
49
+ this._log.info(`Stopping SkewedAspect Game Engine (Version: ${O})...`);
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 k = "0.9.0", fe = 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
- }, pe = class {
75
+ }, A = class {
76
76
  timers;
77
77
  constructor() {
78
78
  this.timers = /* @__PURE__ */ new Map();
@@ -131,7 +131,7 @@ var k = "0.9.0", fe = 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
- }, me = class {
134
+ }, j = class {
135
135
  trace(e, t, ...n) {}
136
136
  debug(e, t, ...n) {}
137
137
  info(e, t, ...n) {}
@@ -139,11 +139,11 @@ var k = "0.9.0", fe = class {
139
139
  error(e, t, ...n) {}
140
140
  time(e, t) {}
141
141
  timeEnd(e, t) {}
142
- }, A = class {
142
+ }, M = class {
143
143
  category;
144
144
  backend;
145
145
  minLevel;
146
- constructor(e, t = "none", n = new me()) {
146
+ constructor(e, t = "none", n = new j()) {
147
147
  this.category = e, this.backend = n, this.minLevel = t;
148
148
  }
149
149
  updateSettings(e, t) {
@@ -181,21 +181,21 @@ var k = "0.9.0", fe = class {
181
181
  default: return !1;
182
182
  }
183
183
  }
184
- }, j = class {
184
+ }, N = class {
185
185
  backend;
186
186
  level;
187
187
  loggers;
188
- constructor(e = "debug", t = new pe()) {
188
+ constructor(e = "debug", t = new A()) {
189
189
  this.backend = t, this.level = e, this.loggers = /* @__PURE__ */ new Map();
190
190
  }
191
191
  setBackend(e) {
192
192
  this.backend = e, this.loggers.forEach((e) => {
193
- e instanceof A && e.updateSettings(this.backend, this.level);
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 A && e.updateSettings(this.backend, this.level);
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 A(e, this.level, this.backend), this.loggers.set(e, t)), t;
206
+ return t || (t = new M(e, this.level, this.backend), this.loggers.set(e, t)), t;
207
207
  }
208
- }, M = class {
208
+ }, P = 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 A("EventBus");
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);
@@ -255,7 +255,7 @@ var k = "0.9.0", fe = class {
255
255
  async $teardown() {
256
256
  this._log.debug("Tearing down EventBus"), this.directMap.clear(), this.patternSubs.clear();
257
257
  }
258
- }, N = class {
258
+ }, F = class {
259
259
  _engine = null;
260
260
  _mainBus = null;
261
261
  _buses = /* @__PURE__ */ new Map();
@@ -299,8 +299,8 @@ var k = "0.9.0", fe = class {
299
299
  };
300
300
  //#endregion
301
301
  //#region src/engines/scene.ts
302
- ce();
303
- var P = class {
302
+ fe();
303
+ var I = class {
304
304
  _canvas;
305
305
  _engine;
306
306
  _havok;
@@ -311,14 +311,14 @@ var P = class {
311
311
  createScene() {
312
312
  return new re(this._engine);
313
313
  }
314
- enablePhysics(e, t = new O(0, -9.8, 0), n) {
314
+ enablePhysics(e, t = new T(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(O.Zero()), r ??= this._canvas, r && i.attachControl(r, !0), i;
321
+ return i.setTarget(T.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 P = class {
329
329
  return i.intensity = r, i;
330
330
  }
331
331
  createPointLight(e, t, n, r = 1) {
332
- let i = new te(e, t, n);
332
+ let i = new C(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 T(e, t, n, r, i, a);
336
+ let s = new oe(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 C(e, t, n, r, i);
340
+ let o = new w(e, t, n, r, i);
341
341
  return o.intensity = a, o;
342
342
  }
343
343
  createSphere(e, t = {}, n) {
344
- return v.CreateSphere(e, {
344
+ return y.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 v.CreateBox(e, {
351
+ return y.CreateBox(e, {
352
352
  size: 1,
353
353
  ...t
354
354
  }, n);
355
355
  }
356
356
  createGround(e, t = {}, n) {
357
- return v.CreateGround(e, {
357
+ return y.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 v.CreateCylinder(e, {
365
+ return y.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 x(e, t, {
373
+ return new ee(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 ee(`${e}`, t);
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;
@@ -398,14 +398,14 @@ var P = class {
398
398
  async $teardown() {
399
399
  this._log.info("Tearing down SceneEngine"), this._log.info("SceneEngine torn down successfully");
400
400
  }
401
- }, F = class {
401
+ }, L = class {
402
402
  _eventBus;
403
403
  _sceneEngine;
404
404
  _log;
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 A("AssetManager");
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("#");
@@ -491,27 +491,27 @@ var P = class {
491
491
  async $teardown() {
492
492
  this.disposeAll();
493
493
  }
494
- }, I = [
494
+ }, R = [
495
495
  "trigger",
496
496
  "toggle",
497
497
  "value"
498
- ], he = [
498
+ ], me = [
499
499
  "keyboard",
500
500
  "mouse",
501
501
  "gamepad"
502
502
  ];
503
- function L(e) {
503
+ function z(e) {
504
504
  return e.type === "keyboard";
505
505
  }
506
- function R(e) {
506
+ function B(e) {
507
507
  return e.type === "mouse";
508
508
  }
509
- function z(e) {
509
+ function V(e) {
510
510
  return e.type === "gamepad";
511
511
  }
512
512
  //#endregion
513
513
  //#region src/classes/bindings/trigger.ts
514
- var ge = class {
514
+ var he = 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
- }, _e = class {
585
+ }, ge = 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
- }, ve = class {
659
+ }, _e = 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
- }, ye = class e {
722
+ }, ve = 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
- }, be = class e {
745
+ }, ye = 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
- }, xe = class e {
780
+ }, be = 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
- }, Se = .05, Ce = .5, we = class {
819
+ }, xe = .05, Se = .5, Ce = 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 A("BindingManager"), this._log.debug("BindingManager initialized");
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) > Se) : !0;
852
+ return B(e) ? Object.values(e.buttons).some((e) => e.pressed) || e.wheel !== void 0 : V(e) ? Object.values(e.buttons).some((e) => e.pressed) || Object.values(e.axes).some((e) => Math.abs(e) > xe) : !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 ge(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
859
+ case "trigger": return new he(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
860
860
  ...e.options || {},
861
861
  context: e.context
862
862
  });
863
- case "toggle": return new _e(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
863
+ case "toggle": return new ge(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
864
864
  ...e.options || {},
865
865
  context: e.context
866
866
  });
867
- case "value": return new ve(t, n, e.input.type, this._createInputSourceFromDefinition(r), {
867
+ case "value": return new _e(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 ye(e.sourceKey, e.options);
876
+ case "keyboard": return new ve(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 be(t, e.sourceKey);
880
+ return new ye(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 xe(t, e.sourceKey, e.options);
885
+ return new be(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 ge = class {
893
893
  let { options: r } = n;
894
894
  if (!r.deviceTypes.includes(e.type)) return;
895
895
  let i = null;
896
- if (L(t)) {
896
+ if (z(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 ge = class {
904
904
  };
905
905
  break;
906
906
  }
907
- } else if (R(t)) {
907
+ } else if (B(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 ge = class {
914
914
  };
915
915
  break;
916
916
  }
917
- } else if (z(t)) {
917
+ } else if (V(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 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]) > Ce) {
928
+ for (let n of Object.keys(t.axes)) if (Math.abs(t.axes[n]) > Se) {
929
929
  i = {
930
930
  type: "gamepad",
931
931
  sourceType: "axis",
@@ -1040,7 +1040,7 @@ var ge = class {
1040
1040
  return this._contexts.get(e) || null;
1041
1041
  }
1042
1042
  $registerBinding(e) {
1043
- if (!I.includes(e.type)) throw Error(`Invalid binding type: ${e.type}`);
1043
+ if (!R.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 ge = class {
1110
1110
  };
1111
1111
  //#endregion
1112
1112
  //#region src/utils/capabilities.ts
1113
- function B() {
1113
+ function H() {
1114
1114
  return typeof window < "u" && window.document !== void 0;
1115
1115
  }
1116
- function V() {
1117
- return B() && !!window.navigator.gpu;
1116
+ function U() {
1117
+ return H() && !!window.navigator.gpu;
1118
1118
  }
1119
1119
  //#endregion
1120
1120
  //#region node_modules/hexoid/dist/index.mjs
1121
- for (var Te = class {
1121
+ for (var we = 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 A("GameManager"), this._boundRenderLoop = this._renderLoop.bind(this), this._boundResizeHandler = this._resizeHandler.bind(this), B() && window.addEventListener("resize", this._boundResizeHandler);
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), H() && 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 Te = class {
1192
1192
  });
1193
1193
  }
1194
1194
  async $teardown() {
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");
1195
+ this._log.info("Tearing down GameManager"), this.started && await this.stop(), H() && window.removeEventListener("resize", this._boundResizeHandler), this._frameCallbacks = [], this._log.info("GameManager torn down successfully");
1196
1196
  }
1197
- }, H = 256, U = []; H--;) U[H] = (H + 256).toString(16).substring(1);
1198
- function Ee(e) {
1197
+ }, W = 256, G = []; W--;) G[W] = (W + 256).toString(16).substring(1);
1198
+ function Te(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 += U[256 * Math.random() | 0];
1203
+ for (t = "", n = (1 + e) / 2 | 0; n--;) t += G[256 * Math.random() | 0];
1204
1204
  t = t.substring(n = 0, e - 2);
1205
1205
  }
1206
- return t + U[n++];
1206
+ return t + G[n++];
1207
1207
  };
1208
1208
  }
1209
1209
  //#endregion
1210
1210
  //#region src/utils/id.ts
1211
- var W = Ee(16), G = class {
1211
+ var Ee = Te(16), K = 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 W = Ee(16), G = class {
1229
1229
  $setEntity(e) {
1230
1230
  this.entity = e;
1231
1231
  }
1232
- }, K = class {
1232
+ }, De = class {
1233
1233
  id;
1234
1234
  type;
1235
1235
  name;
@@ -1244,7 +1244,7 @@ var W = Ee(16), G = class {
1244
1244
  _tags = /* @__PURE__ */ new Set();
1245
1245
  subscriptions = /* @__PURE__ */ new Map();
1246
1246
  constructor(e, t, n, r, i) {
1247
- this.id = W(), this.type = e, this.name = i, this.state = n, this.eventBus = t;
1247
+ this.id = Ee(), 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 W = Ee(16), G = class {
1413
1413
  }
1414
1414
  return this.behaviors.splice(t, 1), n.$setEntity(null), !0;
1415
1415
  }
1416
- }, De = class {
1416
+ }, Oe = 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 A("EntityManager"), this._log.info("EntityManager initialized");
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;
@@ -1537,7 +1537,7 @@ var W = Ee(16), G = 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 K(n.type, this.eventBus, r, n.behaviors, i);
1540
+ let i = t.name ?? n.name, a = new De(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 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
- }, Oe = {
1710
+ }, ke = {
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 ke(e, t) {
1717
+ function Ae(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 = Oe[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) {
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 = ke[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,38 @@ function ke(e, t) {
1728
1728
  }
1729
1729
  //#endregion
1730
1730
  //#region src/handlers/postProcessing.ts
1731
- async function q(e, t) {
1731
+ async function je(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 ke(e, t);
1735
+ } else Ae(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 T(e.x, e.y, e.z);
1748
+ }
1749
+ function Me(e) {
1750
+ return {
1751
+ x: e.x,
1752
+ y: e.y,
1753
+ z: e.z,
1754
+ w: e.w
1755
+ };
1756
+ }
1757
+ function Ne(e) {
1758
+ return new te(e.x, e.y, e.z, e.w);
1736
1759
  }
1737
1760
  //#endregion
1738
1761
  //#region src/classes/level.ts
1739
- var J = class {
1762
+ var Pe = class {
1740
1763
  name;
1741
1764
  _log;
1742
1765
  _context;
@@ -1744,7 +1767,7 @@ var J = class {
1744
1767
  clusteredLights = null;
1745
1768
  outlines = null;
1746
1769
  constructor(e, t) {
1747
- this.name = e.name, this._context = t, this._log = t.logger?.getLogger(`Level:${e.name}`) ?? new A(`Level:${e.name}`, "info");
1770
+ this.name = e.name, this._context = t, this._log = t.logger?.getLogger(`Level:${e.name}`) ?? new M(`Level:${e.name}`, "info");
1748
1771
  }
1749
1772
  get scene() {
1750
1773
  return this._scene;
@@ -1799,7 +1822,7 @@ var J = class {
1799
1822
  this.outlines &&= (this.outlines.dispose(), null), this.clusteredLights &&= (this.clusteredLights.dispose(), null), this._scene.dispose(), this._scene = null;
1800
1823
  }
1801
1824
  }
1802
- }, Ae = class {
1825
+ }, Fe = class {
1803
1826
  _scene;
1804
1827
  _layers = /* @__PURE__ */ new Map();
1805
1828
  constructor(e, t) {
@@ -1843,7 +1866,7 @@ var J = class {
1843
1866
  n.length > 0 && e.layer.addSelection(n);
1844
1867
  }
1845
1868
  }
1846
- }, je = class extends J {
1869
+ }, Ie = class extends Pe {
1847
1870
  _config;
1848
1871
  _spawnPoints = [];
1849
1872
  _entityNodes = [];
@@ -1865,9 +1888,9 @@ var J = class {
1865
1888
  let n = e.createScene();
1866
1889
  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
1890
  let e = this._config.postProcessing.renderer ?? "pipeline";
1868
- this._log.info(`Applying post-processing with ${e} renderer`), await q(n, this._config.postProcessing);
1891
+ this._log.info(`Applying post-processing with ${e} renderer`), await je(n, this._config.postProcessing);
1869
1892
  }
1870
- return this.outlines = new Ae(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;
1893
+ return this.outlines = new Fe(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
1894
  }
1872
1895
  async _loadSceneFile(e) {
1873
1896
  let t = this._getScenePath();
@@ -1898,11 +1921,11 @@ var J = class {
1898
1921
  }
1899
1922
  e.environmentTexture && e.createDefaultSkybox(e.environmentTexture, !0, t.skyboxSize ?? 1e3, 0, !1);
1900
1923
  } else {
1901
- let n = t.skyboxSize ?? 1e3, r = v.CreateSphere("skybox", {
1924
+ let n = t.skyboxSize ?? 1e3, r = y.CreateSphere("skybox", {
1902
1925
  diameter: n,
1903
1926
  segments: 32
1904
- }, e), i = new E("skybox-mat", e);
1905
- i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new ae(t.skybox, e), r.material = i, r.infiniteDistance = !0;
1927
+ }, e), i = new se("skybox-mat", e);
1928
+ i.backFaceCulling = !1, i.disableLighting = !0, i.emissiveTexture = new ce(t.skybox, e), r.material = i, r.infiniteDistance = !0;
1906
1929
  }
1907
1930
  this._log.debug(`Skybox set from: ${t.skybox}`);
1908
1931
  }
@@ -1938,20 +1961,20 @@ var J = class {
1938
1961
  }
1939
1962
  }
1940
1963
  _createCamera(e, t, r) {
1941
- let i = t.position ? this._toVector3(t.position) : O.Zero(), a;
1964
+ let i = t.position ? J(t.position) : T.Zero(), a;
1942
1965
  switch (t.type) {
1943
1966
  case "arcRotate": {
1944
- let i = t.target ? this._toVector3(t.target) : O.Zero();
1967
+ let i = t.target ? J(t.target) : T.Zero();
1945
1968
  a = new n(e, t.alpha ?? Math.PI / 2, t.beta ?? Math.PI / 3, t.radius ?? 10, i, r);
1946
1969
  break;
1947
1970
  }
1948
1971
  case "universal":
1949
- a = new oe(e, i, r);
1972
+ a = new ue(e, i, r);
1950
1973
  break;
1951
1974
  case "geospatial": {
1952
- if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e, O.Zero(), r);
1953
- let n = new le(e, r, { planetRadius: t.planetRadius });
1954
- t.center && (n.center = this._toVector3(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;
1975
+ if (!t.planetRadius) return this._log.warn(`Geospatial camera "${e}" requires planetRadius -- skipping`), new d(e, T.Zero(), r);
1976
+ let n = new E(e, r, { planetRadius: t.planetRadius });
1977
+ 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
1978
  break;
1956
1979
  }
1957
1980
  default:
@@ -1961,7 +1984,7 @@ var J = class {
1961
1984
  return this._applyCameraConfig(a, t), a;
1962
1985
  }
1963
1986
  _applyCameraConfig(e, t) {
1964
- t.fov !== void 0 && (e.fov = t.fov), t.position && (e.position = this._toVector3(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 = this._toVector3(t.rotation))), e instanceof n && (t.target && e.setTarget(this._toVector3(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 = this._toVector3(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));
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 E && (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
1988
  }
1966
1989
  _processLights(e) {
1967
1990
  let t = this._config.lights;
@@ -1971,7 +1994,7 @@ var J = class {
1971
1994
  }
1972
1995
  }
1973
1996
  _createLight(e, t, n) {
1974
- let r = t.direction ? this._toVector3(t.direction) : new O(0, -1, 0), i = t.position ? this._toVector3(t.position) : O.Zero();
1997
+ let r = t.direction ? J(t.direction) : new T(0, -1, 0), i = t.position ? J(t.position) : T.Zero();
1975
1998
  switch (t.type) {
1976
1999
  case "hemispheric": {
1977
2000
  let i = new m(e, r, n);
@@ -1984,20 +2007,20 @@ var J = class {
1984
2007
  break;
1985
2008
  }
1986
2009
  case "point": {
1987
- let r = new te(e, i, n);
2010
+ let r = new C(e, i, n);
1988
2011
  this._applyLightConfig(r, t);
1989
2012
  break;
1990
2013
  }
1991
2014
  case "spot": {
1992
- let a = new T(e, i, r, t.angle ?? Math.PI / 3, t.exponent ?? 2, n);
2015
+ let a = new oe(e, i, r, t.angle ?? Math.PI / 3, t.exponent ?? 2, n);
1993
2016
  this._applyLightConfig(a, t);
1994
2017
  break;
1995
2018
  }
1996
2019
  case "rectarea": {
1997
- let a = new C(e, i, t.width ?? 1, t.height ?? 1, n);
2020
+ let a = new w(e, i, t.width ?? 1, t.height ?? 1, n);
1998
2021
  if (this._applyLightConfig(a, t), t.direction) {
1999
- let t = new D(`${e}_pivot`, n);
2000
- t.position = a.position.clone(), a.position = O.Zero(), a.parent = t, t.lookAt(t.position.subtract(r));
2022
+ let t = new le(`${e}_pivot`, n);
2023
+ t.position = a.position.clone(), a.position = T.Zero(), a.parent = t, t.lookAt(t.position.subtract(r));
2001
2024
  }
2002
2025
  break;
2003
2026
  }
@@ -2009,25 +2032,22 @@ var J = class {
2009
2032
  _setupClustering(e) {
2010
2033
  let t = this._config.clustering;
2011
2034
  if (!t?.enabled) return;
2012
- let n = e.lights.filter((e) => ue.IsLightSupported(e));
2035
+ let n = e.lights.filter((e) => D.IsLightSupported(e));
2013
2036
  if (n.length === 0) {
2014
2037
  this._log.debug("Clustering enabled but no eligible lights found");
2015
2038
  return;
2016
2039
  }
2017
2040
  for (let t of n) e.removeLight(t);
2018
- let r = new ue("sage-clustered", n, e);
2041
+ let r = new D("sage-clustered", n, e);
2019
2042
  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 b && (t.useGLTFLightFalloff = !0);
2021
- }
2022
- _toVector3(e) {
2023
- return new O(e.x, e.y, e.z);
2043
+ for (let t of e.materials) t instanceof x && (t.useGLTFLightFalloff = !0);
2024
2044
  }
2025
2045
  _toColor3(e) {
2026
2046
  return new r(e.r, e.g, e.b);
2027
2047
  }
2028
2048
  async _enablePhysics(e) {
2029
- let t = this._config.physics, n = new O(0, -9.81, 0);
2030
- typeof t == "object" && t.gravity && (n = new O(t.gravity.x, t.gravity.y, t.gravity.z));
2049
+ let t = this._config.physics, n = new T(0, -9.81, 0);
2050
+ typeof t == "object" && t.gravity && (n = new T(t.gravity.x, t.gravity.y, t.gravity.z));
2031
2051
  let r = this.gameEngine.largeWorldRendering ? 1e5 : void 0;
2032
2052
  this._log.debug(`Enabling physics with gravity: ${n.toString()}`), await this.gameEngine.engines.sceneEngine.enablePhysics(e, n, r);
2033
2053
  }
@@ -2050,14 +2070,16 @@ var J = class {
2050
2070
  async _processNodeMetadata(e) {
2051
2071
  "spawn" in e.metadata && this._spawnPoints.push({
2052
2072
  name: e.metadata.spawn,
2053
- position: e.position.clone(),
2054
- rotation: e.rotation.clone(),
2073
+ position: e.getAbsolutePosition(),
2074
+ rotation: e.absoluteRotationQuaternion.clone(),
2055
2075
  scaling: e.scaling.clone(),
2056
2076
  node: e
2057
2077
  }), "entity" in e.metadata && this._entityNodes.push({
2058
2078
  type: e.metadata.entity,
2059
2079
  node: e
2060
- });
2080
+ }), await this._runPropertyHandlers(e);
2081
+ }
2082
+ async _runPropertyHandlers(e) {
2061
2083
  for (let [t, n] of this.propertyHandlers) if (t in e.metadata) try {
2062
2084
  await n(e, e.metadata[t], this, this.gameEngine);
2063
2085
  } catch (n) {
@@ -2081,9 +2103,9 @@ var J = class {
2081
2103
  async _spawnEntity(e, t) {
2082
2104
  let n = {
2083
2105
  ...e.config,
2084
- position: this._vectorToObject(t.position),
2085
- rotation: this._vectorToObject(t.rotation),
2086
- scaling: this._vectorToObject(t.scaling)
2106
+ position: q(t.position),
2107
+ rotation: Me(t.rotation),
2108
+ scaling: q(t.scaling)
2087
2109
  }, r = await this.gameEngine.managers.entityManager.createEntity(e.entity, {
2088
2110
  name: e.name,
2089
2111
  tags: e.tags,
@@ -2091,23 +2113,16 @@ var J = class {
2091
2113
  });
2092
2114
  return await this._createEntityMesh(r, t), r;
2093
2115
  }
2094
- _vectorToObject(e) {
2095
- return {
2096
- x: e.x,
2097
- y: e.y,
2098
- z: e.z
2099
- };
2100
- }
2101
2116
  async _createEntityMesh(e, t) {
2102
2117
  if (!this._scene) return;
2103
2118
  let n = this.gameEngine.managers.entityManager.getDefinition(e.type);
2104
2119
  if (!n?.mesh) return;
2105
- let r = n.mesh, i = this._scene, a = new D(`entity-${e.id}`, i);
2106
- a.position.copyFrom(t.position), a.rotation.copyFrom(t.rotation);
2120
+ let r = n.mesh, i = this._scene, a = new le(`entity-${e.id}`, i);
2121
+ a.position.copyFrom(t.position), a.rotationQuaternion = t.rotation.clone(), a.scaling.copyFrom(t.scaling);
2107
2122
  let o;
2108
2123
  switch (r.source) {
2109
2124
  case "box":
2110
- o = [v.CreateBox(`${e.type}-mesh`, {
2125
+ o = [y.CreateBox(`${e.type}-mesh`, {
2111
2126
  size: r.params?.size ?? 1,
2112
2127
  width: r.params?.width,
2113
2128
  height: r.params?.height,
@@ -2115,19 +2130,19 @@ var J = class {
2115
2130
  }, i)];
2116
2131
  break;
2117
2132
  case "sphere":
2118
- o = [v.CreateSphere(`${e.type}-mesh`, {
2133
+ o = [y.CreateSphere(`${e.type}-mesh`, {
2119
2134
  diameter: r.params?.diameter ?? 1,
2120
2135
  segments: r.params?.segments ?? 16
2121
2136
  }, i)];
2122
2137
  break;
2123
2138
  case "capsule":
2124
- o = [v.CreateCapsule(`${e.type}-mesh`, {
2139
+ o = [y.CreateCapsule(`${e.type}-mesh`, {
2125
2140
  height: r.params?.height ?? 1.8,
2126
2141
  radius: r.params?.radius ?? .4
2127
2142
  }, i)];
2128
2143
  break;
2129
2144
  case "cylinder":
2130
- o = [v.CreateCylinder(`${e.type}-mesh`, {
2145
+ o = [y.CreateCylinder(`${e.type}-mesh`, {
2131
2146
  height: r.params?.height ?? 1,
2132
2147
  diameter: r.params?.diameter ?? 1
2133
2148
  }, i)];
@@ -2149,15 +2164,23 @@ var J = class {
2149
2164
  if (s?.color) {
2150
2165
  let t = s.color;
2151
2166
  if (s.type === "pbr") {
2152
- let n = new b(`${e.type}-material`, i);
2167
+ let n = new x(`${e.type}-material`, i);
2153
2168
  n.albedoColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive)), n.metallic = s.metallic ?? 0, n.roughness = s.roughness ?? 1;
2154
2169
  for (let e of o) e.material = n;
2155
2170
  } else {
2156
- let n = new E(`${e.type}-material`, i);
2171
+ let n = new se(`${e.type}-material`, i);
2157
2172
  n.diffuseColor = this._toColor3(t), s.emissive && (n.emissiveColor = this._toColor3(s.emissive));
2158
2173
  for (let e of o) e.material = n;
2159
2174
  }
2160
2175
  }
2176
+ let c = [...o, ...a.getChildren()];
2177
+ for (let e of c) {
2178
+ let t = this._getNormalizedMetadata(e);
2179
+ t && Object.keys(t).length > 0 && (e.metadata = {
2180
+ ...e.metadata,
2181
+ ...t
2182
+ }, await this._runPropertyHandlers(e));
2183
+ }
2161
2184
  this.gameEngine.managers.entityManager.attachToNode(e, a);
2162
2185
  }
2163
2186
  async _processEntityNodes() {
@@ -2168,7 +2191,7 @@ var J = class {
2168
2191
  try {
2169
2192
  let n = {
2170
2193
  ...t?.config,
2171
- position: this._vectorToObject(e.node.position)
2194
+ position: q(e.node.position)
2172
2195
  }, r = await this.gameEngine.managers.entityManager.createEntity(e.type, {
2173
2196
  name: t?.name ?? e.node.name,
2174
2197
  tags: t?.tags,
@@ -2199,7 +2222,7 @@ var J = class {
2199
2222
  }
2200
2223
  }
2201
2224
  async onDeactivate() {
2202
- for (let [e, t] of this._levelSounds) t.state === w.Started && (this._playingSoundsBeforeDeactivate.add(e), t.pause());
2225
+ for (let [e, t] of this._levelSounds) t.state === ae.Started && (this._playingSoundsBeforeDeactivate.add(e), t.pause());
2203
2226
  }
2204
2227
  async onActivate() {
2205
2228
  for (let e of this._playingSoundsBeforeDeactivate) {
@@ -2220,7 +2243,7 @@ var J = class {
2220
2243
  for (let e of this._levelSounds.values()) e.dispose();
2221
2244
  this._levelSounds.clear(), this._playingSoundsBeforeDeactivate.clear(), await super.$dispose();
2222
2245
  }
2223
- }, Me = class {
2246
+ }, Le = class {
2224
2247
  _eventBus;
2225
2248
  _gameEngine = null;
2226
2249
  _log;
@@ -2238,7 +2261,7 @@ var J = class {
2238
2261
  return this._propertyHandlers;
2239
2262
  }
2240
2263
  constructor(e, t) {
2241
- this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new A("LevelManager"), this._eventUnsubscribers.push(this._eventBus.subscribe("level:progress", (e) => {
2264
+ this._eventBus = e, this._logger = t, this._log = t?.getLogger("LevelManager") || new M("LevelManager"), this._eventUnsubscribers.push(this._eventBus.subscribe("level:progress", (e) => {
2242
2265
  this._handleProgress(e.payload);
2243
2266
  })), this._eventUnsubscribers.push(this._eventBus.subscribe("level:complete", (e) => {
2244
2267
  this._handleComplete(e.payload);
@@ -2273,7 +2296,7 @@ var J = class {
2273
2296
  if (!n) throw Error(`Level class '${e.class}' is not registered.`);
2274
2297
  return this._log.debug(`Creating level '${e.name}' using class '${e.class}'`), new n(e, t);
2275
2298
  }
2276
- return this._log.debug(`Creating level '${e.name}' using GameLevel`), new je(e, t);
2299
+ return this._log.debug(`Creating level '${e.name}' using GameLevel`), new Ie(e, t);
2277
2300
  }
2278
2301
  registerLevelConfig(e) {
2279
2302
  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 +2382,7 @@ var J = class {
2359
2382
  for (let e of this._loadedLevels.values()) await e.$dispose();
2360
2383
  this._loadedLevels.clear(), this._levelConfigs.clear(), this._currentLevel = null;
2361
2384
  }
2362
- }, Ne = class {
2385
+ }, Re = class {
2363
2386
  _audioEngine;
2364
2387
  _channels = /* @__PURE__ */ new Map();
2365
2388
  _masterMuted = !1;
@@ -2430,14 +2453,14 @@ var J = class {
2430
2453
  getChannels() {
2431
2454
  return Array.from(this._channels.keys());
2432
2455
  }
2433
- }, Pe = class {
2456
+ }, ze = class {
2434
2457
  _entityManager;
2435
2458
  _levelManager;
2436
2459
  _log;
2437
2460
  _beforeSerializeHooks = [];
2438
2461
  _afterDeserializeHooks = [];
2439
2462
  constructor(e, t, n) {
2440
- this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new A("SaveManager"), this._log.info("SaveManager initialized");
2463
+ this._entityManager = e, this._levelManager = t, this._log = n?.getLogger("SaveManager") || new M("SaveManager"), this._log.info("SaveManager initialized");
2441
2464
  }
2442
2465
  onBeforeSerialize(e) {
2443
2466
  this._beforeSerializeHooks.push(e);
@@ -2520,7 +2543,7 @@ var J = class {
2520
2543
  async $teardown() {
2521
2544
  this._beforeSerializeHooks = [], this._afterDeserializeHooks = [], this._log.info("SaveManager torn down");
2522
2545
  }
2523
- }, Fe = class {
2546
+ }, Be = class {
2524
2547
  _keyboardDevice;
2525
2548
  _keysState = {};
2526
2549
  _onDeviceConnected;
@@ -2585,7 +2608,7 @@ var J = class {
2585
2608
  _notifyInputChanged(e) {
2586
2609
  this._onInputChanged && this._onInputChanged(this._keyboardDevice, e);
2587
2610
  }
2588
- }, Ie = class {
2611
+ }, Ve = class {
2589
2612
  _targetElement;
2590
2613
  _mouseDevice;
2591
2614
  _buttonState = {};
@@ -2704,7 +2727,7 @@ var J = class {
2704
2727
  _notifyInputChanged(e) {
2705
2728
  this._onInputChanged && this._onInputChanged(this._mouseDevice, e);
2706
2729
  }
2707
- }, Le = class {
2730
+ }, He = class {
2708
2731
  _gamepadDevices = {};
2709
2732
  _buttonStates = {};
2710
2733
  _axesStates = {};
@@ -2838,14 +2861,14 @@ var J = class {
2838
2861
  _notifyInputChanged(e, t) {
2839
2862
  this._onInputChanged && this._onInputChanged(e, t);
2840
2863
  }
2841
- }, Re = class {
2864
+ }, Ue = class {
2842
2865
  _eventBus;
2843
2866
  _keyboardRA;
2844
2867
  _mouseRA;
2845
2868
  _gamepadRA;
2846
2869
  _log;
2847
2870
  constructor(e, t, n) {
2848
- this._eventBus = e, this._log = n?.getLogger("UserInputManager") || new A("UserInputManager"), this._log.info("Initializing UserInputManager"), this._log.debug("Initializing input resource access classes"), this._keyboardRA = new Fe(), this._mouseRA = new Ie(t), this._gamepadRA = new Le(), 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");
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 Be(), this._mouseRA = new Ve(t), this._gamepadRA = new He(), 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
2872
  }
2850
2873
  _publishDeviceConnected(e) {
2851
2874
  this._log.debug(`Device connected: ${e.id} (${e.name})`), this._eventBus.publish({
@@ -2898,18 +2921,18 @@ var J = class {
2898
2921
  };
2899
2922
  //#endregion
2900
2923
  //#region src/utils/graphics.ts
2901
- async function ze(e, t) {
2902
- let n = new se(e, t);
2924
+ async function We(e, t) {
2925
+ let n = new de(e, t);
2903
2926
  return await n.initAsync(), n;
2904
2927
  }
2905
2928
  function Y(e, t) {
2906
2929
  return new l(e, t.antialias, t.options, t.adaptToDeviceRatio);
2907
2930
  }
2908
- function Be(e) {
2909
- return new y(e);
2931
+ function Ge(e) {
2932
+ return new b(e);
2910
2933
  }
2911
- async function Ve(e, t, n = !1) {
2912
- if (e === null) return console.debug("Using Null Engine"), Be(t);
2934
+ async function Ke(e, t, n = !1) {
2935
+ if (e === null) return console.debug("Using Null Engine"), Ge(t);
2913
2936
  if (n) if ("options" in t) {
2914
2937
  let e = t;
2915
2938
  t = {
@@ -2924,15 +2947,15 @@ async function Ve(e, t, n = !1) {
2924
2947
  useLargeWorldRendering: !0
2925
2948
  };
2926
2949
  let r = t.engine || "auto";
2927
- if (r === "webgpu") if (V()) try {
2928
- return console.debug("Using forced WebGPU engine"), await ze(e, t);
2950
+ if (r === "webgpu") if (U()) try {
2951
+ return console.debug("Using forced WebGPU engine"), await We(e, t);
2929
2952
  } catch (e) {
2930
2953
  throw console.error("Forced WebGPU initialization failed:", e), Error("Forced WebGPU failed to initialize. If WebGPU is required, check browser compatibility.", { cause: e });
2931
2954
  }
2932
2955
  else throw Error("WebGPU was forced but is not available in this browser.");
2933
2956
  if (r === "webgl") return console.debug("Using forced WebGL engine"), Y(e, t);
2934
- if (V()) try {
2935
- return console.debug("Using WebGPU"), ze(e, t).catch((n) => (console.warn("WebGPU initialization failed, falling back to WebGL:", n), Y(e, t)));
2957
+ if (U()) try {
2958
+ return console.debug("Using WebGPU"), We(e, t).catch((n) => (console.warn("WebGPU initialization failed, falling back to WebGL:", n), Y(e, t)));
2936
2959
  } catch (e) {
2937
2960
  console.warn("WebGPU initialization failed, falling back to WebGL:", e);
2938
2961
  }
@@ -2941,15 +2964,15 @@ async function Ve(e, t, n = !1) {
2941
2964
  }
2942
2965
  //#endregion
2943
2966
  //#region src/utils/physics.ts
2944
- async function He() {
2945
- return await de();
2967
+ async function qe() {
2968
+ return await pe();
2946
2969
  }
2947
- function Ue(e) {
2970
+ function Je(e) {
2948
2971
  return new p(!0, e);
2949
2972
  }
2950
2973
  //#endregion
2951
2974
  //#region src/utils/raycast.ts
2952
- var We = class {
2975
+ var Ye = class {
2953
2976
  _entityManager;
2954
2977
  constructor(e) {
2955
2978
  this._entityManager = e;
@@ -3015,7 +3038,7 @@ var We = class {
3015
3038
  pickingInfo: e
3016
3039
  };
3017
3040
  }
3018
- }, Ge = class {
3041
+ }, Xe = class {
3019
3042
  _nextId = 0;
3020
3043
  _delays = [];
3021
3044
  _intervals = [];
@@ -3070,21 +3093,21 @@ var We = class {
3070
3093
  for (let t of this._intervals) for (t.elapsed += e; t.elapsed >= t.periodMs;) t.callback(), t.elapsed -= t.periodMs;
3071
3094
  for (let t of this._cooldowns) t.remaining > 0 && (t.remaining = Math.max(0, t.remaining - e));
3072
3095
  }
3073
- }, Ke = [
3096
+ }, Ze = [
3074
3097
  "trace",
3075
3098
  "debug",
3076
3099
  "info",
3077
3100
  "warn",
3078
3101
  "error",
3079
3102
  "none"
3080
- ], qe = class extends G {
3103
+ ], Qe = class extends K {
3081
3104
  name = "sound";
3082
3105
  eventSubscriptions = [];
3083
3106
  _sounds = /* @__PURE__ */ new Map();
3084
3107
  _initialized = !1;
3085
3108
  _audioManager = null;
3086
3109
  _node = null;
3087
- _log = new A("SoundBehavior");
3110
+ _log = new M("SoundBehavior");
3088
3111
  onNodeAttached(e, t) {
3089
3112
  if (this._initialized) return;
3090
3113
  if (this._node = e, this._initialized = !0, this._log = t.logger.getLogger("SoundBehavior"), t.managers.audioManager) this._audioManager = t.managers.audioManager;
@@ -3146,7 +3169,7 @@ var We = class {
3146
3169
  } else for (let t of this._sounds.values()) t.volume = e;
3147
3170
  }
3148
3171
  isPlaying(e) {
3149
- return this._getSound(e)?.state === w.Started;
3172
+ return this._getSound(e)?.state === ae.Started;
3150
3173
  }
3151
3174
  getSoundNames() {
3152
3175
  return Array.from(this._sounds.keys());
@@ -3222,7 +3245,7 @@ var We = class {
3222
3245
  }
3223
3246
  });
3224
3247
  }
3225
- }, Je = class extends G {
3248
+ }, $e = class extends K {
3226
3249
  name = "stateMachine";
3227
3250
  eventSubscriptions = [];
3228
3251
  stateMachine;
@@ -3241,7 +3264,7 @@ var We = class {
3241
3264
  }
3242
3265
  static create(e) {
3243
3266
  let { initialState: t, stateKey: n, transitions: r, wildcardTransitions: i } = e;
3244
- class a extends Je {
3267
+ class a extends $e {
3245
3268
  constructor() {
3246
3269
  super(), this.stateKey = n, this.stateMachine = new X(t);
3247
3270
  for (let e of r) this.stateMachine.addTransition(e.from, e.to, e.guard);
@@ -3250,58 +3273,58 @@ var We = class {
3250
3273
  }
3251
3274
  return a;
3252
3275
  }
3253
- }, Z = new A("ColliderHandler");
3276
+ }, Z = new M("ColliderHandler");
3254
3277
  function Q(e, t, n) {
3255
3278
  let r = e.getScene();
3256
- new x(e, t, { mass: n }, r);
3279
+ new ee(e, t, { mass: n }, r);
3257
3280
  }
3258
- function Ye(e, t) {
3281
+ function et(e, t) {
3259
3282
  let n = e.getChildMeshes().find((e) => e.metadata?.collider_mesh === !0);
3260
- n instanceof _ ? (n.isVisible = !1, Q(n, S.MESH, t)) : Q(e, S.MESH, t);
3283
+ n instanceof v ? (n.isVisible = !1, Q(n, S.MESH, t)) : Q(e, S.MESH, t);
3261
3284
  }
3262
- function Xe(e) {
3263
- e.registerPropertyHandler("collider", (e, t, n, r) => {
3264
- let i = t;
3265
- if (Z.debug(`Processing collider: ${e.name} -> ${i} (isMesh: ${e instanceof _})`), !n.scene) throw Error("Scene not available for collider handler");
3266
- if (!(e instanceof _)) {
3267
- Z.warn(`Skipping collider for ${e.name}: not a Mesh instance`);
3285
+ function tt(t) {
3286
+ t.registerPropertyHandler("collider", (t, n, r, i) => {
3287
+ let a = n;
3288
+ if (Z.debug(`Processing collider: ${t.name} -> ${a} (isMesh: ${t instanceof v})`), !r.scene) throw Error("Scene not available for collider handler");
3289
+ if (!(t instanceof v) && a === "mesh") {
3290
+ Z.warn(`Skipping mesh collider for ${t.name}: not a Mesh instance`);
3268
3291
  return;
3269
3292
  }
3270
- let a = e.metadata?.collider_mass ?? 0;
3271
- switch (i) {
3293
+ let o = t.metadata?.collider_mass ?? 0;
3294
+ switch (a) {
3272
3295
  case "box":
3273
- Q(e, S.BOX, a);
3296
+ Q(t, S.BOX, o);
3274
3297
  break;
3275
3298
  case "sphere":
3276
- Q(e, S.SPHERE, a);
3299
+ Q(t, S.SPHERE, o);
3277
3300
  break;
3278
3301
  case "mesh":
3279
- Ye(e, a);
3302
+ et(t, o);
3280
3303
  break;
3281
3304
  case "none":
3282
- e.checkCollisions = !1;
3305
+ t instanceof e && (t.checkCollisions = !1);
3283
3306
  break;
3284
- default: Z.warn(`Unknown collider type: ${i}`);
3307
+ default: Z.warn(`Unknown collider type: ${a}`);
3285
3308
  }
3286
- if (e.metadata?.collider_kinematic) {
3287
- let t = e;
3288
- t.physicsBody && (t.physicsBody.disablePreStep = !1);
3309
+ if (t.metadata?.collider_kinematic) {
3310
+ let e = t;
3311
+ e.physicsBody && (e.physicsBody.disablePreStep = !1);
3289
3312
  }
3290
3313
  });
3291
3314
  }
3292
3315
  //#endregion
3293
3316
  //#region src/handlers/lod.ts
3294
- var Ze = new A("LodHandler");
3295
- function Qe(e) {
3317
+ var nt = new M("LodHandler");
3318
+ function rt(e) {
3296
3319
  return e.split(",").map((e) => parseFloat(e.trim())).filter((e) => !isNaN(e));
3297
3320
  }
3298
- function $e(e) {
3321
+ function it(e) {
3299
3322
  e.registerPropertyHandler("lod_distances", (e, t, n, r) => {
3300
3323
  let i = t;
3301
- if (!(e instanceof _)) return;
3302
- let a = Qe(i);
3324
+ if (!(e instanceof v)) return;
3325
+ let a = rt(i);
3303
3326
  if (a.length === 0) {
3304
- Ze.warn(`Invalid lod_distances value: ${i}`);
3327
+ nt.warn(`Invalid lod_distances value: ${i}`);
3305
3328
  return;
3306
3329
  }
3307
3330
  let o = e.getChildMeshes(!0), s = Math.min(a.length, o.length);
@@ -3314,12 +3337,12 @@ function $e(e) {
3314
3337
  //#region src/handlers/occluder.ts
3315
3338
  function $(e) {
3316
3339
  e.registerPropertyHandler("occluder", (e, t, n, r) => {
3317
- t && e instanceof _ && (e.isOccluder = !0, e.isVisible = !1);
3340
+ t && e instanceof v && (e.isOccluder = !0, e.isVisible = !1);
3318
3341
  });
3319
3342
  }
3320
3343
  //#endregion
3321
3344
  //#region src/utils/metadata.ts
3322
- function et(e, t) {
3345
+ function at(e, t) {
3323
3346
  let n = {}, r = `${t}_`;
3324
3347
  for (let [t, i] of Object.entries(e)) if (t.startsWith(r)) {
3325
3348
  let e = t.slice(r.length);
@@ -3329,14 +3352,14 @@ function et(e, t) {
3329
3352
  }
3330
3353
  //#endregion
3331
3354
  //#region src/handlers/sound.ts
3332
- var tt = new A("SoundHandler");
3333
- function nt(e) {
3355
+ var ot = new M("SoundHandler");
3356
+ function st(e) {
3334
3357
  e.registerPropertyHandler("sound", (e, t, n, r) => {
3335
3358
  let i = t;
3336
3359
  if (!n.scene) throw Error("Scene not available for sound handler");
3337
- let a = et(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;
3360
+ let a = at(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
3361
  if (!f) {
3339
- tt.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
3362
+ ot.warn(`No AudioManager available. Sound for "${e.name}" skipped.`);
3340
3363
  return;
3341
3364
  }
3342
3365
  f.createSound(`${e.name}_sound`, i, d, {
@@ -3349,13 +3372,13 @@ function nt(e) {
3349
3372
  }).then((t) => {
3350
3373
  c && t.spatial.attach(e);
3351
3374
  }).catch((t) => {
3352
- tt.error(`Failed to create sound for node "${e.name}": ${t}`);
3375
+ ot.error(`Failed to create sound for node "${e.name}": ${t}`);
3353
3376
  });
3354
3377
  });
3355
3378
  }
3356
3379
  //#endregion
3357
3380
  //#region src/handlers/trigger.ts
3358
- function rt(e, n, r, i, a) {
3381
+ function ct(e, n, r, i, a) {
3359
3382
  let o = a === "enter" ? t.OnIntersectionEnterTrigger : t.OnIntersectionExitTrigger, s = `trigger:${a}`;
3360
3383
  e.registerAction(new u({
3361
3384
  trigger: o,
@@ -3370,10 +3393,10 @@ function rt(e, n, r, i, a) {
3370
3393
  });
3371
3394
  }));
3372
3395
  }
3373
- function it(e, t, n, r) {
3374
- rt(e, t, n, r, "enter"), rt(e, t, n, r, "exit");
3396
+ function lt(e, t, n, r) {
3397
+ ct(e, t, n, r, "enter"), ct(e, t, n, r, "exit");
3375
3398
  }
3376
- function at(n) {
3399
+ function ut(n) {
3377
3400
  n.registerPropertyHandler("trigger", (n, r, i, a) => {
3378
3401
  let o = r, s = i.scene;
3379
3402
  if (!s) throw Error("Scene not available for trigger handler");
@@ -3382,9 +3405,9 @@ function at(n) {
3382
3405
  n.isVisible = !1, n.checkCollisions = !0;
3383
3406
  let l = n.actionManager ?? new t(s);
3384
3407
  n.actionManager = l;
3385
- for (let e of s.meshes) e !== n && !e.metadata?.trigger && it(l, o, c, e);
3408
+ for (let e of s.meshes) e !== n && !e.metadata?.trigger && lt(l, o, c, e);
3386
3409
  let u = s.onNewMeshAddedObservable.add((e) => {
3387
- e !== n && !e.metadata?.trigger && it(l, o, c, e);
3410
+ e !== n && !e.metadata?.trigger && lt(l, o, c, e);
3388
3411
  });
3389
3412
  n.onDisposeObservable.add(() => {
3390
3413
  s.onNewMeshAddedObservable.remove(u);
@@ -3393,7 +3416,7 @@ function at(n) {
3393
3416
  }
3394
3417
  //#endregion
3395
3418
  //#region src/handlers/visible.ts
3396
- function ot(t) {
3419
+ function dt(t) {
3397
3420
  t.registerPropertyHandler("visible", (t, n, r, i) => {
3398
3421
  if (!(t instanceof e)) return;
3399
3422
  let a = !0;
@@ -3402,39 +3425,39 @@ function ot(t) {
3402
3425
  }
3403
3426
  //#endregion
3404
3427
  //#region src/handlers/index.ts
3405
- function st(e) {
3406
- Xe(e), $e(e), $(e), nt(e), at(e), ot(e);
3428
+ function ft(e) {
3429
+ tt(e), it(e), $(e), st(e), ut(e), dt(e);
3407
3430
  }
3408
3431
  //#endregion
3409
3432
  //#region src/sage.ts
3410
- async function ct(e, t, n = {}) {
3411
- let r = new j(n.logLevel || "debug"), i = r.getLogger("SAGE");
3412
- i.info(`Initializing SAGE Game Engine v${k}...`), i.debug("Creating rendering engine...");
3413
- let a = await Ve(e, {
3433
+ async function pt(e, t, n = {}) {
3434
+ let r = new N(n.logLevel || "debug"), i = r.getLogger("SAGE");
3435
+ i.info(`Initializing SAGE Game Engine v${O}...`), i.debug("Creating rendering engine...");
3436
+ let a = await Ke(e, {
3414
3437
  antialias: !0,
3415
3438
  adaptToDeviceRatio: !0,
3416
3439
  ...n.renderOptions
3417
3440
  }, n.largeWorldRendering ?? !1);
3418
3441
  i.debug("Creating physics engine...");
3419
- let o = await He(), s = Ue(o);
3442
+ let o = await qe(), s = Je(o);
3420
3443
  i.debug("Creating event bus...");
3421
- let c = new M(r);
3444
+ let c = new P(r);
3422
3445
  i.debug("Creating scene engine...");
3423
- let l = new P(e, a, o, r);
3446
+ let l = new I(e, a, o, r);
3424
3447
  i.debug("Creating managers...");
3425
- let u = new F(c, l, r), d = new Re(c, e, r), f = new we(c, r), p = new De(c, r, f), m = new Me(c, r), h = new Pe(p, m, r), g = new Te(a, c, p, d, m, r);
3448
+ let u = new L(c, l, r), d = new Ue(c, e, r), f = new Ce(c, r), p = new Oe(c, r, f), m = new Le(c, r), h = new ze(p, m, r), g = new we(a, c, p, d, m, r);
3426
3449
  i.debug("Creating raycast helper...");
3427
- let ee = new We(p);
3450
+ let _ = new Ye(p);
3428
3451
  i.debug("Creating game timer...");
3429
- let _ = new Ge();
3430
- g.registerFrameCallback((e) => _.tick(e * 1e3));
3431
- let v, y;
3432
- n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), v = new N(r), await v.initialize(), i.debug("Creating audio manager..."), y = new Ne(v, r), await y.initialize(n.audioChannels)), i.info(`SAGE Game Engine v${k} initialized successfully.`), i.debug("Loading entities...");
3452
+ let v = new Xe();
3453
+ g.registerFrameCallback((e) => v.tick(e * 1e3));
3454
+ let y, b;
3455
+ n.audioChannels && n.audioChannels.length > 0 && (i.debug("Creating audio engine..."), y = new F(r), await y.initialize(), i.debug("Creating audio manager..."), b = new Re(y, r), await b.initialize(n.audioChannels)), i.info(`SAGE Game Engine v${O} initialized successfully.`), i.debug("Loading entities...");
3433
3456
  for (let e of t) p.registerEntityDefinition(e);
3434
3457
  if (i.debug("Registering default input bindings..."), n.bindings) for (let e of n.bindings) f.registerBinding(e);
3435
- let b = new fe(e, a, s, c, r, ee, _, {
3458
+ let x = new k(e, a, s, c, r, _, v, {
3436
3459
  sceneEngine: l,
3437
- audioEngine: v
3460
+ audioEngine: y
3438
3461
  }, {
3439
3462
  assetManager: u,
3440
3463
  bindingManager: f,
@@ -3443,11 +3466,11 @@ async function ct(e, t, n = {}) {
3443
3466
  inputManager: d,
3444
3467
  levelManager: m,
3445
3468
  saveManager: h,
3446
- audioManager: y
3469
+ audioManager: b
3447
3470
  }, n.largeWorldRendering ?? !1);
3448
- return p.$setGameEngine(b), m.$setGameEngine(b), b;
3471
+ return p.$setGameEngine(x), m.$setGameEngine(x), x;
3449
3472
  }
3450
3473
  //#endregion
3451
- export { F as AssetManager, N as AudioEngine, Ne as AudioManager, pe as ConsoleBackend, fe as GameEngine, K as GameEntity, G as GameEntityBehavior, M as GameEventBus, je as GameLevel, Ge as GameTimer, J as Level, Ke as LogLevels, j as LoggingUtility, me as NullBackend, Ae as OutlineManager, We as RaycastHelper, A as SAGELogger, Pe as SaveManager, P as SceneEngine, qe as SoundBehavior, X as StateMachine, Je as StateMachineBehavior, k as VERSION, q as applyPostProcessing, I as bindingTypes, et as collectPrefixedProperties, ct as createGameEngine, W as generateId, z as isGamepadState, L as isKeyboardState, R as isMouseState, st as registerAllPropertyHandlers, Xe as registerColliderHandler, $e as registerLodHandler, $ as registerOccluderHandler, nt as registerSoundHandler, at as registerTriggerHandler, ot as registerVisibleHandler, he as validDeviceTypes };
3474
+ export { L as AssetManager, F as AudioEngine, Re as AudioManager, A as ConsoleBackend, k as GameEngine, De as GameEntity, K as GameEntityBehavior, P as GameEventBus, Ie as GameLevel, Xe as GameTimer, Pe as Level, Ze as LogLevels, N as LoggingUtility, j as NullBackend, Fe as OutlineManager, Ye as RaycastHelper, M as SAGELogger, ze as SaveManager, I as SceneEngine, Qe as SoundBehavior, X as StateMachine, $e as StateMachineBehavior, O as VERSION, je as applyPostProcessing, R as bindingTypes, at as collectPrefixedProperties, pt as createGameEngine, Ee as generateId, V as isGamepadState, z as isKeyboardState, B as isMouseState, ft as registerAllPropertyHandlers, tt as registerColliderHandler, it as registerLodHandler, $ as registerOccluderHandler, st as registerSoundHandler, ut as registerTriggerHandler, dt as registerVisibleHandler, Me as toQuatObject, Ne as toQuaternion, q as toVec3Object, J as toVector3, me as validDeviceTypes };
3452
3475
 
3453
3476
  //# sourceMappingURL=sage.es.js.map