@nativewrappers/fivem 0.0.22 → 0.0.24

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.
@@ -9,26 +9,19 @@ export interface Vec2 {
9
9
  /**
10
10
  * Represents a 3-dimensional vector.
11
11
  */
12
- export interface Vec3 {
13
- x: number;
14
- y: number;
12
+ export interface Vec3 extends Vec2 {
15
13
  z: number;
16
14
  }
17
15
  /**
18
16
  * Represents a 4-dimensional vector.
19
17
  */
20
- export interface Vec4 {
21
- x: number;
22
- y: number;
23
- z: number;
18
+ export interface Vec4 extends Vec3 {
24
19
  w: number;
25
20
  }
26
21
  /**
27
22
  * An object with vector components.
28
23
  */
29
- interface VectorObject {
30
- x: number;
31
- y: number;
24
+ export interface Vec extends Vec2 {
32
25
  z?: number;
33
26
  w?: number;
34
27
  }
@@ -47,7 +40,7 @@ type VectorType = typeof Vector;
47
40
  /**
48
41
  * Represents an object or class that can be treated as a vector.
49
42
  */
50
- type VectorLike = VectorObject | Vector;
43
+ type VectorLike = Vec | Vector;
51
44
  /**
52
45
  * Utility type to get the vector type of an object based on its component.
53
46
  */
@@ -121,14 +114,14 @@ export declare class Vector {
121
114
  * @param z - The value to add to the z-component.
122
115
  * @returns A new vector with the z-component incremented.
123
116
  */
124
- static addZ<T extends VectorType, U extends VectorLike>(this: T, obj: U, z: number): InferVector<U>;
117
+ static addZ<T extends VectorType, U extends Vec3 | Vec4>(this: T, obj: U, z: number): InferVector<U>;
125
118
  /**
126
119
  * Adds a scalar value to the w-component of a vector.
127
120
  * @param obj - The vector.
128
121
  * @param w - The value to add to the w-component.
129
122
  * @returns A new vector with the w-component incremented.
130
123
  */
131
- static addW<T extends VectorType, U extends VectorLike>(this: T, obj: U, w: number): InferVector<U>;
124
+ static addW<T extends VectorType, U extends Vec4>(this: T, obj: U, w: number): InferVector<U>;
132
125
  /**
133
126
  * Subtracts one vector from another or subtracts a scalar value from a vector.
134
127
  * @param a - The vector.
@@ -163,7 +156,7 @@ export declare class Vector {
163
156
  * @param b - The second vector.
164
157
  * @returns A new vector perpendicular to both input vectors.
165
158
  */
166
- static crossProduct<T extends VectorType, U extends VectorObject>(this: T, a: U, b: U): U;
159
+ static crossProduct<T extends VectorType, U extends Vec3 | Vec4>(this: T, a: U, b: U): U;
167
160
  /**
168
161
  * Normalizes a vector, producing a new vector with the same direction but with a magnitude of 1.
169
162
  * @param vector - The vector to be normalized.
@@ -256,7 +249,7 @@ export declare class Vector {
256
249
  /**
257
250
  * Converts the vector to an array of its components.
258
251
  */
259
- toArray(): number[];
252
+ toArray<T extends this>(): VectorArray<T>;
260
253
  /**
261
254
  * Replaces the components of the vector with the components of another vector object.
262
255
  * @param v - The object whose components will replace the current vector's components.
@@ -302,7 +295,7 @@ export declare class Vector3 extends Vector implements Vec3 {
302
295
  /**
303
296
  * @see Vector.crossProduct
304
297
  */
305
- crossProduct(v: VectorLike): VectorLike;
298
+ crossProduct(v: Vec3 | Vec4): Vec3 | Vec4;
306
299
  }
307
300
  /**
308
301
  * Represents a 4-dimensional vector.
@@ -331,6 +324,6 @@ export declare class Vector4 extends Vector {
331
324
  /**
332
325
  * @see Vector.crossProduct
333
326
  */
334
- crossProduct(v: VectorLike): VectorLike;
327
+ crossProduct(v: Vec3 | Vec4): Vec3 | Vec4;
335
328
  }
336
329
  export {};
@@ -155,11 +155,9 @@ export class Vector {
155
155
  static dotProduct(a, b) {
156
156
  let result = 0;
157
157
  for (const key of ['x', 'y', 'z', 'w']) {
158
- const v1 = a[key];
159
- const v2 = b[key];
160
- if (v1 && v2)
161
- result += v1 * v2;
162
- else if (v1 || v2) {
158
+ if (key in a && key in b)
159
+ result += a[key] * b[key];
160
+ else {
163
161
  throw new Error('Vectors must have the same dimensions');
164
162
  }
165
163
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Remco Troost <d0p3t>",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.22",
7
+ "version": "0.0.24",
8
8
  "publishConfig": {
9
9
  "directory": "lib"
10
10
  },