quake2ts 0.0.589 → 0.0.591
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/package.json +1 -1
- package/packages/test-utils/dist/index.cjs +15 -2
- package/packages/test-utils/dist/index.cjs.map +1 -1
- package/packages/test-utils/dist/index.d.cts +5 -1
- package/packages/test-utils/dist/index.d.ts +5 -1
- package/packages/test-utils/dist/index.js +15 -2
- package/packages/test-utils/dist/index.js.map +1 -1
|
@@ -1221,8 +1221,12 @@ interface CameraInput {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
/**
|
|
1223
1223
|
* Creates a mock Camera instance with optional overrides.
|
|
1224
|
+
* Accepts partial Camera properties, where position/angles can be Vec3 objects or arrays.
|
|
1224
1225
|
*/
|
|
1225
|
-
declare function createMockCamera(overrides?: Partial<Camera>
|
|
1226
|
+
declare function createMockCamera(overrides?: Partial<Omit<Camera, 'position' | 'angles'> & {
|
|
1227
|
+
position: any;
|
|
1228
|
+
angles: any;
|
|
1229
|
+
}>): Camera;
|
|
1226
1230
|
/**
|
|
1227
1231
|
* Creates a mock RefDef object.
|
|
1228
1232
|
*/
|
|
@@ -1221,8 +1221,12 @@ interface CameraInput {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
/**
|
|
1223
1223
|
* Creates a mock Camera instance with optional overrides.
|
|
1224
|
+
* Accepts partial Camera properties, where position/angles can be Vec3 objects or arrays.
|
|
1224
1225
|
*/
|
|
1225
|
-
declare function createMockCamera(overrides?: Partial<Camera>
|
|
1226
|
+
declare function createMockCamera(overrides?: Partial<Omit<Camera, 'position' | 'angles'> & {
|
|
1227
|
+
position: any;
|
|
1228
|
+
angles: any;
|
|
1229
|
+
}>): Camera;
|
|
1226
1230
|
/**
|
|
1227
1231
|
* Creates a mock RefDef object.
|
|
1228
1232
|
*/
|
|
@@ -472,6 +472,7 @@ function createTestContext(options) {
|
|
|
472
472
|
multicast: vi2.fn(),
|
|
473
473
|
unicast: vi2.fn(),
|
|
474
474
|
engine,
|
|
475
|
+
scriptHooks: hooks,
|
|
475
476
|
game,
|
|
476
477
|
sound: vi2.fn((ent, chan, sound, vol, attn, timeofs) => {
|
|
477
478
|
engine.sound(ent, chan, sound, vol, attn, timeofs);
|
|
@@ -2901,13 +2902,25 @@ var forEach = (function() {
|
|
|
2901
2902
|
|
|
2902
2903
|
// src/client/helpers/view.ts
|
|
2903
2904
|
import { Camera } from "@quake2ts/engine";
|
|
2905
|
+
function toVec3(v) {
|
|
2906
|
+
if (v instanceof Float32Array && v.length === 3) {
|
|
2907
|
+
return v;
|
|
2908
|
+
}
|
|
2909
|
+
if (Array.isArray(v) && v.length === 3) {
|
|
2910
|
+
return vec3_exports.fromValues(v[0], v[1], v[2]);
|
|
2911
|
+
}
|
|
2912
|
+
if (typeof v === "object" && "x" in v && "y" in v && "z" in v) {
|
|
2913
|
+
return vec3_exports.fromValues(v.x, v.y, v.z);
|
|
2914
|
+
}
|
|
2915
|
+
return vec3_exports.create();
|
|
2916
|
+
}
|
|
2904
2917
|
function createMockCamera(overrides = {}) {
|
|
2905
2918
|
const camera = new Camera();
|
|
2906
2919
|
if (overrides.position) {
|
|
2907
|
-
camera.position = overrides.position;
|
|
2920
|
+
camera.position = toVec3(overrides.position);
|
|
2908
2921
|
}
|
|
2909
2922
|
if (overrides.angles) {
|
|
2910
|
-
camera.angles = overrides.angles;
|
|
2923
|
+
camera.angles = toVec3(overrides.angles);
|
|
2911
2924
|
}
|
|
2912
2925
|
if (overrides.fov !== void 0) {
|
|
2913
2926
|
camera.fov = overrides.fov;
|