@nativewrappers/fivem 0.0.27 → 0.0.28
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/common/utils/Vector.d.ts +0 -1
- package/common/utils/Vector.js +11 -16
- package/package.json +1 -1
package/common/utils/Vector.d.ts
CHANGED
|
@@ -196,7 +196,6 @@ export declare class Vector {
|
|
|
196
196
|
constructor(size: number, x?: number, y?: number, z?: number | undefined, w?: number | undefined);
|
|
197
197
|
[Symbol.iterator](): Iterator<number>;
|
|
198
198
|
toString(): string;
|
|
199
|
-
toJSON(): string;
|
|
200
199
|
/**
|
|
201
200
|
* @see Vector.clone
|
|
202
201
|
*/
|
package/common/utils/Vector.js
CHANGED
|
@@ -17,16 +17,14 @@ export class Vector {
|
|
|
17
17
|
return new Vector2(x, x);
|
|
18
18
|
if (typeof x === 'object')
|
|
19
19
|
({ x, y, z, w } = x);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
: `vec${[x, y, z, w].filter(arg => arg !== undefined).length}`;
|
|
23
|
-
switch (type) {
|
|
20
|
+
const size = this instanceof Vector ? this.size : [x, y, z, w].filter(arg => arg !== undefined).length;
|
|
21
|
+
switch (size) {
|
|
24
22
|
default:
|
|
25
|
-
case
|
|
23
|
+
case 2:
|
|
26
24
|
return new Vector2(x, y);
|
|
27
|
-
case
|
|
25
|
+
case 3:
|
|
28
26
|
return new Vector3(x, y, z);
|
|
29
|
-
case
|
|
27
|
+
case 4:
|
|
30
28
|
return new Vector4(x, y, z, w);
|
|
31
29
|
}
|
|
32
30
|
}
|
|
@@ -156,11 +154,12 @@ export class Vector {
|
|
|
156
154
|
static dotProduct(a, b) {
|
|
157
155
|
let result = 0;
|
|
158
156
|
for (const key of ['x', 'y', 'z', 'w']) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
const x = a[key];
|
|
158
|
+
const y = b[key];
|
|
159
|
+
if (!!x && !!y)
|
|
160
|
+
result += x * y;
|
|
161
|
+
else if (x || y)
|
|
162
162
|
throw new Error('Vectors must have the same dimensions');
|
|
163
|
-
}
|
|
164
163
|
}
|
|
165
164
|
return result;
|
|
166
165
|
}
|
|
@@ -259,11 +258,7 @@ export class Vector {
|
|
|
259
258
|
yield this.w;
|
|
260
259
|
}
|
|
261
260
|
toString() {
|
|
262
|
-
|
|
263
|
-
return `${this.type}(${[x, y, z, w].filter(val => val !== undefined).join(', ')})`;
|
|
264
|
-
}
|
|
265
|
-
toJSON() {
|
|
266
|
-
return this.toString();
|
|
261
|
+
return `vector${this.size}(${this.toArray().join(', ')})`;
|
|
267
262
|
}
|
|
268
263
|
/**
|
|
269
264
|
* @see Vector.clone
|