@nativewrappers/fivem 0.0.36 → 0.0.38
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/client/World.d.ts +2 -0
- package/client/World.js +8 -1
- package/common/utils/Vector.d.ts +9 -9
- package/common/utils/Vector.js +14 -12
- package/package.json +1 -1
package/client/World.d.ts
CHANGED
|
@@ -363,6 +363,8 @@ export declare abstract class World {
|
|
|
363
363
|
* @returns {@see AsynchronousRaycastResult} object that must be awaited to get its results.
|
|
364
364
|
*/
|
|
365
365
|
static raycast(start: Vector3, end: Vector3, losFlags?: IntersectFlags, shapeTestOptions?: number, ignoreEntity?: BaseEntity): AsynchronousRaycastResult;
|
|
366
|
+
static raycastDirection(useExpensiveRaycast: true, source: Vector3, direction: Vector3, maxDistance: number): SynchronousRaycastResult;
|
|
367
|
+
static raycastDirection(useExpensiveRaycast: false, source: Vector3, direction: Vector3, maxDistance: number): AsynchronousRaycastResult;
|
|
366
368
|
/**
|
|
367
369
|
* Cast a ray from the local players camera until it hits an entity
|
|
368
370
|
*
|
package/client/World.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Ped, Vehicle } from './models';
|
|
|
8
8
|
import { Pickup } from './Pickup';
|
|
9
9
|
import { AsynchronousRaycastResult, SynchronousRaycastResult } from './Raycast';
|
|
10
10
|
import { Rope } from './Rope';
|
|
11
|
-
import { Maths, Wait } from './utils';
|
|
11
|
+
import { Maths, Vector3, Wait } from './utils';
|
|
12
12
|
/**
|
|
13
13
|
* Class with common world manipulations.
|
|
14
14
|
*
|
|
@@ -612,6 +612,13 @@ export class World {
|
|
|
612
612
|
static raycast(start, end, losFlags = IntersectFlags.All, shapeTestOptions = SHAPE_TEST_DEFAULT, ignoreEntity) {
|
|
613
613
|
return new AsynchronousRaycastResult(StartShapeTestLosProbe(start.x, start.y, start.z, end.x, end.y, end.z, losFlags, ignoreEntity?.Handle ?? 0, shapeTestOptions));
|
|
614
614
|
}
|
|
615
|
+
static raycastDirection(useExpensiveRaycast, source, direction, maxDistance, losFlags = IntersectFlags.All, shapeTestOptions = SHAPE_TEST_DEFAULT, ignoreEntity) {
|
|
616
|
+
const target = Vector3.add(source, Vector3.multiply(direction, maxDistance));
|
|
617
|
+
if (useExpensiveRaycast) {
|
|
618
|
+
return new SynchronousRaycastResult(StartExpensiveSynchronousShapeTestLosProbe(source.x, source.y, source.z, target.x, target.y, target.z, losFlags, ignoreEntity?.Handle ?? 0, shapeTestOptions));
|
|
619
|
+
}
|
|
620
|
+
return new AsynchronousRaycastResult(StartShapeTestLosProbe(source.x, source.y, source.z, target.x, target.y, target.z, losFlags, ignoreEntity?.Handle ?? 0, shapeTestOptions));
|
|
621
|
+
}
|
|
615
622
|
/**
|
|
616
623
|
* Cast a ray from the local players camera until it hits an entity
|
|
617
624
|
*
|
package/common/utils/Vector.d.ts
CHANGED
|
@@ -206,7 +206,7 @@ export declare class Vector {
|
|
|
206
206
|
* Creates a vector from an array or object containing vector components.
|
|
207
207
|
* @param primitive The object to use as a vector.
|
|
208
208
|
*/
|
|
209
|
-
static fromObject<T extends VectorType, U extends InferVector<T> | VectorArray<T>>(this: T, primitive: U): InstanceType<T>;
|
|
209
|
+
static fromObject<T extends VectorType, U extends InferVector<T> | VectorArray<T>>(this: T, primitive: U | MsgpackBuffer): InstanceType<T>;
|
|
210
210
|
/**
|
|
211
211
|
* Creates an array of vectors from an array of number arrays
|
|
212
212
|
* @param primitives A multi-dimensional array of number arrays
|
|
@@ -280,8 +280,8 @@ export declare class Vector {
|
|
|
280
280
|
*/
|
|
281
281
|
divide(v: VectorLike | number): this;
|
|
282
282
|
/**
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
* @see Vector.addAbsolute
|
|
284
|
+
*/
|
|
285
285
|
addAbsolute(v: VectorLike): this;
|
|
286
286
|
/**
|
|
287
287
|
* @see Vector.subtractAbsolute
|
|
@@ -346,8 +346,8 @@ export declare class Vector3 extends Vector implements Vec3 {
|
|
|
346
346
|
*/
|
|
347
347
|
crossProduct(v: Vec3 | Vec4): Vec3 | Vec4;
|
|
348
348
|
/**
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
* @returns the x and y values as Vec2
|
|
350
|
+
*/
|
|
351
351
|
toVec2(): Vector2;
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
@@ -379,12 +379,12 @@ export declare class Vector4 extends Vector {
|
|
|
379
379
|
*/
|
|
380
380
|
crossProduct(v: Vec3 | Vec4): Vec3 | Vec4;
|
|
381
381
|
/**
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
* @returns the x and y values as Vec2
|
|
383
|
+
*/
|
|
384
384
|
toVec2(): Vector2;
|
|
385
385
|
/**
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
* @returns the x and y values as Vec3
|
|
387
|
+
*/
|
|
388
388
|
toVec3(): Vector3;
|
|
389
389
|
}
|
|
390
390
|
export {};
|
package/common/utils/Vector.js
CHANGED
|
@@ -57,12 +57,12 @@ export class Vector {
|
|
|
57
57
|
static operate(a, b, operator) {
|
|
58
58
|
let { x, y, z, w } = a;
|
|
59
59
|
const isNumber = typeof b === 'number';
|
|
60
|
-
x = operator(x, isNumber ? b : b.x ?? 0);
|
|
61
|
-
y = operator(y, isNumber ? b : b.y ?? 0);
|
|
60
|
+
x = operator(x, isNumber ? b : (b.x ?? 0));
|
|
61
|
+
y = operator(y, isNumber ? b : (b.y ?? 0));
|
|
62
62
|
if (z)
|
|
63
|
-
z = operator(z, isNumber ? b : b.z ?? 0);
|
|
63
|
+
z = operator(z, isNumber ? b : (b.z ?? 0));
|
|
64
64
|
if (w)
|
|
65
|
-
w = operator(w, isNumber ? b : b.w ?? 0);
|
|
65
|
+
w = operator(w, isNumber ? b : (b.w ?? 0));
|
|
66
66
|
return this.create(x, y, z, w);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -259,6 +259,8 @@ export class Vector {
|
|
|
259
259
|
static fromObject(primitive) {
|
|
260
260
|
if (Array.isArray(primitive))
|
|
261
261
|
return this.fromArray(primitive);
|
|
262
|
+
if ('buffer' in primitive && 'type' in primitive)
|
|
263
|
+
return this.fromBuffer(primitive);
|
|
262
264
|
const { x, y, z, w } = primitive;
|
|
263
265
|
return this.create(x, y, z, w);
|
|
264
266
|
}
|
|
@@ -387,8 +389,8 @@ export class Vector {
|
|
|
387
389
|
return Vector.divide(this, v);
|
|
388
390
|
}
|
|
389
391
|
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
* @see Vector.addAbsolute
|
|
393
|
+
*/
|
|
392
394
|
addAbsolute(v) {
|
|
393
395
|
return Vector.addAbsolute(this, v);
|
|
394
396
|
}
|
|
@@ -484,8 +486,8 @@ export class Vector3 extends Vector {
|
|
|
484
486
|
return Vector.crossProduct(this, v);
|
|
485
487
|
}
|
|
486
488
|
/**
|
|
487
|
-
|
|
488
|
-
|
|
489
|
+
* @returns the x and y values as Vec2
|
|
490
|
+
*/
|
|
489
491
|
toVec2() {
|
|
490
492
|
return new Vector2(this.x, this.y);
|
|
491
493
|
}
|
|
@@ -529,14 +531,14 @@ export class Vector4 extends Vector {
|
|
|
529
531
|
return Vector.crossProduct(this, v);
|
|
530
532
|
}
|
|
531
533
|
/**
|
|
532
|
-
|
|
533
|
-
|
|
534
|
+
* @returns the x and y values as Vec2
|
|
535
|
+
*/
|
|
534
536
|
toVec2() {
|
|
535
537
|
return new Vector2(this.x, this.y);
|
|
536
538
|
}
|
|
537
539
|
/**
|
|
538
|
-
|
|
539
|
-
|
|
540
|
+
* @returns the x and y values as Vec3
|
|
541
|
+
*/
|
|
540
542
|
toVec3() {
|
|
541
543
|
return new Vector3(this.x, this.y, this.z);
|
|
542
544
|
}
|