quake2ts 0.0.407 → 0.0.410

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.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +16 -16
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +463 -74
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +463 -74
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/client/dist/types/demo/handler.d.ts +3 -0
  10. package/packages/client/dist/types/demo/handler.d.ts.map +1 -1
  11. package/packages/client/dist/types/effects-system.d.ts +17 -0
  12. package/packages/client/dist/types/effects-system.d.ts.map +1 -0
  13. package/packages/client/dist/types/index.d.ts +2 -0
  14. package/packages/client/dist/types/index.d.ts.map +1 -1
  15. package/packages/client/dist/types/net/connection.d.ts +21 -4
  16. package/packages/client/dist/types/net/connection.d.ts.map +1 -1
  17. package/packages/engine/dist/browser/index.global.js +14 -14
  18. package/packages/engine/dist/browser/index.global.js.map +1 -1
  19. package/packages/engine/dist/cjs/index.cjs +91 -7
  20. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  21. package/packages/engine/dist/esm/index.js +90 -7
  22. package/packages/engine/dist/esm/index.js.map +1 -1
  23. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  24. package/packages/engine/dist/types/assets/headlessLoader.d.ts +11 -0
  25. package/packages/engine/dist/types/assets/headlessLoader.d.ts.map +1 -0
  26. package/packages/engine/dist/types/index.d.ts +1 -1
  27. package/packages/engine/dist/types/index.d.ts.map +1 -1
  28. package/packages/engine/dist/types/render/bsp/generator.d.ts +25 -0
  29. package/packages/engine/dist/types/render/bsp/generator.d.ts.map +1 -0
  30. package/packages/engine/dist/types/render/bsp/geometry.d.ts.map +1 -1
  31. package/packages/engine/dist/types/render/camera.d.ts +11 -0
  32. package/packages/engine/dist/types/render/camera.d.ts.map +1 -1
  33. package/packages/engine/dist/types/render/cameraController.d.ts +23 -0
  34. package/packages/engine/dist/types/render/cameraController.d.ts.map +1 -0
  35. package/packages/engine/dist/types/render/debug.d.ts +20 -0
  36. package/packages/engine/dist/types/render/debug.d.ts.map +1 -0
  37. package/packages/engine/dist/types/render/options.d.ts +9 -0
  38. package/packages/engine/dist/types/render/options.d.ts.map +1 -0
  39. package/packages/engine/dist/types/render/renderer.d.ts +4 -1
  40. package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
  41. package/packages/engine/dist/types/render/types.d.ts +22 -0
  42. package/packages/engine/dist/types/render/types.d.ts.map +1 -0
  43. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  DemoReader: () => DemoReader,
51
51
  DemoRecorder: () => DemoRecorder,
52
52
  DemoValidator: () => DemoValidator,
53
+ DynamicLightManager: () => DynamicLightManager,
53
54
  EngineHost: () => EngineHost,
54
55
  EngineRuntime: () => EngineRuntime,
55
56
  FileType: () => FileType,
@@ -377,6 +378,7 @@ function normalizeVec3(a) {
377
378
  var DEG2RAD_FACTOR = Math.PI / 180;
378
379
  var RAD2DEG_FACTOR = 180 / Math.PI;
379
380
  var DEG2RAD = DEG2RAD_FACTOR;
381
+ var RAD2DEG = RAD2DEG_FACTOR;
380
382
  var ANORMS = [
381
383
  [-0.525731, 0, 0.850651],
382
384
  [-0.442863, 0.238856, 0.864188],
@@ -5684,6 +5686,43 @@ function gatherVisibleFaces(map, cameraPosition, frustum) {
5684
5686
 
5685
5687
  // src/render/dlight.ts
5686
5688
  var MAX_DLIGHTS = 32;
5689
+ var DynamicLightManager = class {
5690
+ constructor() {
5691
+ this.lights = [];
5692
+ }
5693
+ /**
5694
+ * Adds a dynamic light or updates an existing one with the same key.
5695
+ */
5696
+ addLight(dlight, time) {
5697
+ if (dlight.key !== void 0) {
5698
+ const index = this.lights.findIndex((l) => l.key === dlight.key);
5699
+ if (index !== -1) {
5700
+ this.lights[index] = dlight;
5701
+ return;
5702
+ }
5703
+ }
5704
+ this.lights.push(dlight);
5705
+ }
5706
+ /**
5707
+ * Clears all lights (e.g., map change).
5708
+ */
5709
+ clear() {
5710
+ this.lights = [];
5711
+ }
5712
+ /**
5713
+ * Updates the list of active lights, removing expired ones.
5714
+ * @param time Current game time in seconds.
5715
+ */
5716
+ update(time) {
5717
+ this.lights = this.lights.filter((l) => l.die > time);
5718
+ }
5719
+ /**
5720
+ * Returns the current list of active lights.
5721
+ */
5722
+ getActiveLights() {
5723
+ return this.lights;
5724
+ }
5725
+ };
5687
5726
 
5688
5727
  // src/render/geometry.ts
5689
5728
  function generateWireframeIndices(indices) {
@@ -6535,15 +6574,21 @@ var Camera = class {
6535
6574
  return this._position;
6536
6575
  }
6537
6576
  set position(value) {
6538
- import_gl_matrix.vec3.copy(this._position, value);
6539
- this._dirty = true;
6577
+ if (!import_gl_matrix.vec3.equals(this._position, value)) {
6578
+ import_gl_matrix.vec3.copy(this._position, value);
6579
+ this._dirty = true;
6580
+ this.triggerMoveEvent();
6581
+ }
6540
6582
  }
6541
6583
  get angles() {
6542
6584
  return this._angles;
6543
6585
  }
6544
6586
  set angles(value) {
6545
- import_gl_matrix.vec3.copy(this._angles, value);
6546
- this._dirty = true;
6587
+ if (!import_gl_matrix.vec3.equals(this._angles, value)) {
6588
+ import_gl_matrix.vec3.copy(this._angles, value);
6589
+ this._dirty = true;
6590
+ this.triggerMoveEvent();
6591
+ }
6547
6592
  }
6548
6593
  get bobAngles() {
6549
6594
  return this._bobAngles;
@@ -6587,6 +6632,47 @@ var Camera = class {
6587
6632
  this._aspect = value;
6588
6633
  this._dirty = true;
6589
6634
  }
6635
+ // API Methods
6636
+ setPosition(x, y, z) {
6637
+ const newPos = import_gl_matrix.vec3.fromValues(x, y, z);
6638
+ if (!import_gl_matrix.vec3.equals(this._position, newPos)) {
6639
+ import_gl_matrix.vec3.copy(this._position, newPos);
6640
+ this._dirty = true;
6641
+ this.triggerMoveEvent();
6642
+ }
6643
+ }
6644
+ setRotation(pitch, yaw, roll) {
6645
+ const newAngles = import_gl_matrix.vec3.fromValues(pitch, yaw, roll);
6646
+ if (!import_gl_matrix.vec3.equals(this._angles, newAngles)) {
6647
+ import_gl_matrix.vec3.copy(this._angles, newAngles);
6648
+ this._dirty = true;
6649
+ this.triggerMoveEvent();
6650
+ }
6651
+ }
6652
+ setFov(fov) {
6653
+ this.fov = fov;
6654
+ }
6655
+ setAspectRatio(aspect) {
6656
+ this.aspect = aspect;
6657
+ }
6658
+ lookAt(target) {
6659
+ const direction = import_gl_matrix.vec3.create();
6660
+ import_gl_matrix.vec3.subtract(direction, target, this._position);
6661
+ const len = import_gl_matrix.vec3.length(direction);
6662
+ if (len < 1e-3) return;
6663
+ const yaw = Math.atan2(direction[1], direction[0]) * RAD2DEG;
6664
+ const hyp = Math.hypot(direction[0], direction[1]);
6665
+ const pitch = -Math.atan2(direction[2], hyp) * RAD2DEG;
6666
+ this.setRotation(pitch, yaw, 0);
6667
+ }
6668
+ triggerMoveEvent() {
6669
+ if (this.onCameraMove) {
6670
+ this.onCameraMove({
6671
+ position: import_gl_matrix.vec3.clone(this._position),
6672
+ angles: import_gl_matrix.vec3.clone(this._angles)
6673
+ });
6674
+ }
6675
+ }
6590
6676
  get viewMatrix() {
6591
6677
  this.updateMatrices();
6592
6678
  return this._viewMatrix;
@@ -6662,11 +6748,8 @@ var Camera = class {
6662
6748
  import_gl_matrix.vec3.transformMat4(rotatedPosQuake, negativePosition, rotationQuake);
6663
6749
  const translationGl = import_gl_matrix.vec3.fromValues(
6664
6750
  rotatedPosQuake[1] || 0,
6665
- // Y in Quake -> X in WebGL (negation already applied above)
6666
6751
  rotatedPosQuake[2] || 0,
6667
- // Z in Quake -> Y in WebGL
6668
6752
  rotatedPosQuake[0] || 0
6669
- // X in Quake -> Z in WebGL (negation already applied above)
6670
6753
  );
6671
6754
  import_gl_matrix.mat4.copy(this._viewMatrix, rotationGl);
6672
6755
  this._viewMatrix[12] = translationGl[0];
@@ -13730,6 +13813,7 @@ function createEngine(imports) {
13730
13813
  DemoReader,
13731
13814
  DemoRecorder,
13732
13815
  DemoValidator,
13816
+ DynamicLightManager,
13733
13817
  EngineHost,
13734
13818
  EngineRuntime,
13735
13819
  FileType,