quake2ts 0.0.408 → 0.0.412

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 (53) 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 +492 -81
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +492 -81
  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 +142 -14
  20. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  21. package/packages/engine/dist/esm/index.js +141 -14
  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/assets/vfs.d.ts +1 -0
  27. package/packages/engine/dist/types/assets/vfs.d.ts.map +1 -1
  28. package/packages/engine/dist/types/editor/bsp-inspector.d.ts +28 -0
  29. package/packages/engine/dist/types/editor/bsp-inspector.d.ts.map +1 -0
  30. package/packages/engine/dist/types/index.d.ts +1 -1
  31. package/packages/engine/dist/types/index.d.ts.map +1 -1
  32. package/packages/engine/dist/types/render/bsp/generator.d.ts +25 -0
  33. package/packages/engine/dist/types/render/bsp/generator.d.ts.map +1 -0
  34. package/packages/engine/dist/types/render/bsp/geometry.d.ts.map +1 -1
  35. package/packages/engine/dist/types/render/camera.d.ts +15 -0
  36. package/packages/engine/dist/types/render/camera.d.ts.map +1 -1
  37. package/packages/engine/dist/types/render/cameraController.d.ts +28 -0
  38. package/packages/engine/dist/types/render/cameraController.d.ts.map +1 -0
  39. package/packages/engine/dist/types/render/debug.d.ts +20 -0
  40. package/packages/engine/dist/types/render/debug.d.ts.map +1 -0
  41. package/packages/engine/dist/types/render/options.d.ts +9 -0
  42. package/packages/engine/dist/types/render/options.d.ts.map +1 -0
  43. package/packages/engine/dist/types/render/renderer.d.ts +4 -1
  44. package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
  45. package/packages/engine/dist/types/render/types.d.ts +22 -0
  46. package/packages/engine/dist/types/render/types.d.ts.map +1 -0
  47. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  48. package/packages/game/dist/types/editor/metadata.d.ts +31 -0
  49. package/packages/game/dist/types/editor/metadata.d.ts.map +1 -0
  50. package/packages/game/dist/types/editor/search.d.ts +9 -0
  51. package/packages/game/dist/types/editor/search.d.ts.map +1 -0
  52. package/packages/game/dist/types/editor/selection.d.ts +19 -0
  53. package/packages/game/dist/types/editor/selection.d.ts.map +1 -0
@@ -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],
@@ -1832,6 +1833,28 @@ var VirtualFileSystem = class {
1832
1833
  async readBinaryFile(path) {
1833
1834
  return this.readFile(path);
1834
1835
  }
1836
+ streamFile(path, chunkSize = 1024 * 1024) {
1837
+ const source = this.files.get(normalizePath(path));
1838
+ if (!source) {
1839
+ throw new Error(`File not found in VFS: ${path}`);
1840
+ }
1841
+ const { archive, entry } = source;
1842
+ const fullData = archive.readFile(path);
1843
+ let offset = 0;
1844
+ const totalSize = fullData.length;
1845
+ return new ReadableStream({
1846
+ pull(controller) {
1847
+ if (offset >= totalSize) {
1848
+ controller.close();
1849
+ return;
1850
+ }
1851
+ const end = Math.min(offset + chunkSize, totalSize);
1852
+ const chunk = fullData.slice(offset, end);
1853
+ offset = end;
1854
+ controller.enqueue(chunk);
1855
+ }
1856
+ });
1857
+ }
1835
1858
  async readTextFile(path) {
1836
1859
  const data = await this.readFile(path);
1837
1860
  return new TextDecoder("utf-8").decode(data);
@@ -5482,6 +5505,43 @@ function gatherVisibleFaces(map, cameraPosition, frustum) {
5482
5505
 
5483
5506
  // src/render/dlight.ts
5484
5507
  var MAX_DLIGHTS = 32;
5508
+ var DynamicLightManager = class {
5509
+ constructor() {
5510
+ this.lights = [];
5511
+ }
5512
+ /**
5513
+ * Adds a dynamic light or updates an existing one with the same key.
5514
+ */
5515
+ addLight(dlight, time) {
5516
+ if (dlight.key !== void 0) {
5517
+ const index = this.lights.findIndex((l) => l.key === dlight.key);
5518
+ if (index !== -1) {
5519
+ this.lights[index] = dlight;
5520
+ return;
5521
+ }
5522
+ }
5523
+ this.lights.push(dlight);
5524
+ }
5525
+ /**
5526
+ * Clears all lights (e.g., map change).
5527
+ */
5528
+ clear() {
5529
+ this.lights = [];
5530
+ }
5531
+ /**
5532
+ * Updates the list of active lights, removing expired ones.
5533
+ * @param time Current game time in seconds.
5534
+ */
5535
+ update(time) {
5536
+ this.lights = this.lights.filter((l) => l.die > time);
5537
+ }
5538
+ /**
5539
+ * Returns the current list of active lights.
5540
+ */
5541
+ getActiveLights() {
5542
+ return this.lights;
5543
+ }
5544
+ };
5485
5545
 
5486
5546
  // src/render/geometry.ts
5487
5547
  function generateWireframeIndices(indices) {
@@ -6333,15 +6393,21 @@ var Camera = class {
6333
6393
  return this._position;
6334
6394
  }
6335
6395
  set position(value) {
6336
- vec3.copy(this._position, value);
6337
- this._dirty = true;
6396
+ if (!vec3.equals(this._position, value)) {
6397
+ vec3.copy(this._position, value);
6398
+ this._dirty = true;
6399
+ this.triggerMoveEvent();
6400
+ }
6338
6401
  }
6339
6402
  get angles() {
6340
6403
  return this._angles;
6341
6404
  }
6342
6405
  set angles(value) {
6343
- vec3.copy(this._angles, value);
6344
- this._dirty = true;
6406
+ if (!vec3.equals(this._angles, value)) {
6407
+ vec3.copy(this._angles, value);
6408
+ this._dirty = true;
6409
+ this.triggerMoveEvent();
6410
+ }
6345
6411
  }
6346
6412
  get bobAngles() {
6347
6413
  return this._bobAngles;
@@ -6385,6 +6451,47 @@ var Camera = class {
6385
6451
  this._aspect = value;
6386
6452
  this._dirty = true;
6387
6453
  }
6454
+ // API Methods
6455
+ setPosition(x, y, z) {
6456
+ const newPos = vec3.fromValues(x, y, z);
6457
+ if (!vec3.equals(this._position, newPos)) {
6458
+ vec3.copy(this._position, newPos);
6459
+ this._dirty = true;
6460
+ this.triggerMoveEvent();
6461
+ }
6462
+ }
6463
+ setRotation(pitch, yaw, roll) {
6464
+ const newAngles = vec3.fromValues(pitch, yaw, roll);
6465
+ if (!vec3.equals(this._angles, newAngles)) {
6466
+ vec3.copy(this._angles, newAngles);
6467
+ this._dirty = true;
6468
+ this.triggerMoveEvent();
6469
+ }
6470
+ }
6471
+ setFov(fov) {
6472
+ this.fov = fov;
6473
+ }
6474
+ setAspectRatio(aspect) {
6475
+ this.aspect = aspect;
6476
+ }
6477
+ lookAt(target) {
6478
+ const direction = vec3.create();
6479
+ vec3.subtract(direction, target, this._position);
6480
+ const len = vec3.length(direction);
6481
+ if (len < 1e-3) return;
6482
+ const yaw = Math.atan2(direction[1], direction[0]) * RAD2DEG;
6483
+ const hyp = Math.hypot(direction[0], direction[1]);
6484
+ const pitch = -Math.atan2(direction[2], hyp) * RAD2DEG;
6485
+ this.setRotation(pitch, yaw, 0);
6486
+ }
6487
+ triggerMoveEvent() {
6488
+ if (this.onCameraMove) {
6489
+ this.onCameraMove({
6490
+ position: vec3.clone(this._position),
6491
+ angles: vec3.clone(this._angles)
6492
+ });
6493
+ }
6494
+ }
6388
6495
  get viewMatrix() {
6389
6496
  this.updateMatrices();
6390
6497
  return this._viewMatrix;
@@ -6408,6 +6515,25 @@ var Camera = class {
6408
6515
  );
6409
6516
  return projectionMatrix;
6410
6517
  }
6518
+ screenToWorldRay(screenX, screenY) {
6519
+ const ndcX = screenX * 2 - 1;
6520
+ const ndcY = 1 - screenY * 2;
6521
+ const clipStart = vec3.fromValues(ndcX, ndcY, -1);
6522
+ const clipEnd = vec3.fromValues(ndcX, ndcY, 1);
6523
+ const invViewProj = mat4.create();
6524
+ mat4.invert(invViewProj, this.viewProjectionMatrix);
6525
+ const worldStart = vec3.create();
6526
+ const worldEnd = vec3.create();
6527
+ vec3.transformMat4(worldStart, clipStart, invViewProj);
6528
+ vec3.transformMat4(worldEnd, clipEnd, invViewProj);
6529
+ const direction = vec3.create();
6530
+ vec3.subtract(direction, worldEnd, worldStart);
6531
+ vec3.normalize(direction, direction);
6532
+ return {
6533
+ origin: vec3.clone(this._position),
6534
+ direction
6535
+ };
6536
+ }
6411
6537
  updateMatrices() {
6412
6538
  if (!this._dirty) {
6413
6539
  return;
@@ -6421,20 +6547,20 @@ var Camera = class {
6421
6547
  );
6422
6548
  const quakeToGl = mat4.fromValues(
6423
6549
  0,
6424
- -1,
6425
6550
  0,
6551
+ -1,
6426
6552
  0,
6427
- // column 0: Quake X -> WebGL (0, -1, 0)
6553
+ // column 0: Quake X -> WebGL -Z
6554
+ -1,
6428
6555
  0,
6429
6556
  0,
6430
- 1,
6431
6557
  0,
6432
- // column 1: Quake Y -> WebGL (0, 0, 1)
6433
- -1,
6558
+ // column 1: Quake Y -> WebGL -X
6434
6559
  0,
6560
+ 1,
6435
6561
  0,
6436
6562
  0,
6437
- // column 2: Quake Z -> WebGL (-1, 0, 0)
6563
+ // column 2: Quake Z -> WebGL Y
6438
6564
  0,
6439
6565
  0,
6440
6566
  0,
@@ -6459,12 +6585,12 @@ var Camera = class {
6459
6585
  const rotatedPosQuake = vec3.create();
6460
6586
  vec3.transformMat4(rotatedPosQuake, negativePosition, rotationQuake);
6461
6587
  const translationGl = vec3.fromValues(
6462
- rotatedPosQuake[1] || 0,
6463
- // Y in Quake -> X in WebGL (negation already applied above)
6588
+ rotatedPosQuake[1] ? -rotatedPosQuake[1] : 0,
6589
+ // Y in Quake -> -X in WebGL
6464
6590
  rotatedPosQuake[2] || 0,
6465
6591
  // Z in Quake -> Y in WebGL
6466
- rotatedPosQuake[0] || 0
6467
- // X in Quake -> Z in WebGL (negation already applied above)
6592
+ rotatedPosQuake[0] ? -rotatedPosQuake[0] : 0
6593
+ // X in Quake -> -Z in WebGL
6468
6594
  );
6469
6595
  mat4.copy(this._viewMatrix, rotationGl);
6470
6596
  this._viewMatrix[12] = translationGl[0];
@@ -13527,6 +13653,7 @@ export {
13527
13653
  DemoReader,
13528
13654
  DemoRecorder,
13529
13655
  DemoValidator,
13656
+ DynamicLightManager,
13530
13657
  EngineHost,
13531
13658
  EngineRuntime,
13532
13659
  FileType,