quake2ts 0.0.408 → 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
@@ -175,6 +175,7 @@ function normalizeVec3(a) {
175
175
  var DEG2RAD_FACTOR = Math.PI / 180;
176
176
  var RAD2DEG_FACTOR = 180 / Math.PI;
177
177
  var DEG2RAD = DEG2RAD_FACTOR;
178
+ var RAD2DEG = RAD2DEG_FACTOR;
178
179
  var ANORMS = [
179
180
  [-0.525731, 0, 0.850651],
180
181
  [-0.442863, 0.238856, 0.864188],
@@ -5482,6 +5483,43 @@ function gatherVisibleFaces(map, cameraPosition, frustum) {
5482
5483
 
5483
5484
  // src/render/dlight.ts
5484
5485
  var MAX_DLIGHTS = 32;
5486
+ var DynamicLightManager = class {
5487
+ constructor() {
5488
+ this.lights = [];
5489
+ }
5490
+ /**
5491
+ * Adds a dynamic light or updates an existing one with the same key.
5492
+ */
5493
+ addLight(dlight, time) {
5494
+ if (dlight.key !== void 0) {
5495
+ const index = this.lights.findIndex((l) => l.key === dlight.key);
5496
+ if (index !== -1) {
5497
+ this.lights[index] = dlight;
5498
+ return;
5499
+ }
5500
+ }
5501
+ this.lights.push(dlight);
5502
+ }
5503
+ /**
5504
+ * Clears all lights (e.g., map change).
5505
+ */
5506
+ clear() {
5507
+ this.lights = [];
5508
+ }
5509
+ /**
5510
+ * Updates the list of active lights, removing expired ones.
5511
+ * @param time Current game time in seconds.
5512
+ */
5513
+ update(time) {
5514
+ this.lights = this.lights.filter((l) => l.die > time);
5515
+ }
5516
+ /**
5517
+ * Returns the current list of active lights.
5518
+ */
5519
+ getActiveLights() {
5520
+ return this.lights;
5521
+ }
5522
+ };
5485
5523
 
5486
5524
  // src/render/geometry.ts
5487
5525
  function generateWireframeIndices(indices) {
@@ -6333,15 +6371,21 @@ var Camera = class {
6333
6371
  return this._position;
6334
6372
  }
6335
6373
  set position(value) {
6336
- vec3.copy(this._position, value);
6337
- this._dirty = true;
6374
+ if (!vec3.equals(this._position, value)) {
6375
+ vec3.copy(this._position, value);
6376
+ this._dirty = true;
6377
+ this.triggerMoveEvent();
6378
+ }
6338
6379
  }
6339
6380
  get angles() {
6340
6381
  return this._angles;
6341
6382
  }
6342
6383
  set angles(value) {
6343
- vec3.copy(this._angles, value);
6344
- this._dirty = true;
6384
+ if (!vec3.equals(this._angles, value)) {
6385
+ vec3.copy(this._angles, value);
6386
+ this._dirty = true;
6387
+ this.triggerMoveEvent();
6388
+ }
6345
6389
  }
6346
6390
  get bobAngles() {
6347
6391
  return this._bobAngles;
@@ -6385,6 +6429,47 @@ var Camera = class {
6385
6429
  this._aspect = value;
6386
6430
  this._dirty = true;
6387
6431
  }
6432
+ // API Methods
6433
+ setPosition(x, y, z) {
6434
+ const newPos = vec3.fromValues(x, y, z);
6435
+ if (!vec3.equals(this._position, newPos)) {
6436
+ vec3.copy(this._position, newPos);
6437
+ this._dirty = true;
6438
+ this.triggerMoveEvent();
6439
+ }
6440
+ }
6441
+ setRotation(pitch, yaw, roll) {
6442
+ const newAngles = vec3.fromValues(pitch, yaw, roll);
6443
+ if (!vec3.equals(this._angles, newAngles)) {
6444
+ vec3.copy(this._angles, newAngles);
6445
+ this._dirty = true;
6446
+ this.triggerMoveEvent();
6447
+ }
6448
+ }
6449
+ setFov(fov) {
6450
+ this.fov = fov;
6451
+ }
6452
+ setAspectRatio(aspect) {
6453
+ this.aspect = aspect;
6454
+ }
6455
+ lookAt(target) {
6456
+ const direction = vec3.create();
6457
+ vec3.subtract(direction, target, this._position);
6458
+ const len = vec3.length(direction);
6459
+ if (len < 1e-3) return;
6460
+ const yaw = Math.atan2(direction[1], direction[0]) * RAD2DEG;
6461
+ const hyp = Math.hypot(direction[0], direction[1]);
6462
+ const pitch = -Math.atan2(direction[2], hyp) * RAD2DEG;
6463
+ this.setRotation(pitch, yaw, 0);
6464
+ }
6465
+ triggerMoveEvent() {
6466
+ if (this.onCameraMove) {
6467
+ this.onCameraMove({
6468
+ position: vec3.clone(this._position),
6469
+ angles: vec3.clone(this._angles)
6470
+ });
6471
+ }
6472
+ }
6388
6473
  get viewMatrix() {
6389
6474
  this.updateMatrices();
6390
6475
  return this._viewMatrix;
@@ -6460,11 +6545,8 @@ var Camera = class {
6460
6545
  vec3.transformMat4(rotatedPosQuake, negativePosition, rotationQuake);
6461
6546
  const translationGl = vec3.fromValues(
6462
6547
  rotatedPosQuake[1] || 0,
6463
- // Y in Quake -> X in WebGL (negation already applied above)
6464
6548
  rotatedPosQuake[2] || 0,
6465
- // Z in Quake -> Y in WebGL
6466
6549
  rotatedPosQuake[0] || 0
6467
- // X in Quake -> Z in WebGL (negation already applied above)
6468
6550
  );
6469
6551
  mat4.copy(this._viewMatrix, rotationGl);
6470
6552
  this._viewMatrix[12] = translationGl[0];
@@ -13527,6 +13609,7 @@ export {
13527
13609
  DemoReader,
13528
13610
  DemoRecorder,
13529
13611
  DemoValidator,
13612
+ DynamicLightManager,
13530
13613
  EngineHost,
13531
13614
  EngineRuntime,
13532
13615
  FileType,