Skip to content

Commit

Permalink
shared: add Vector3::cross typings (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiin authored Oct 30, 2023
1 parent ce5d446 commit 5ff7b9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shared/js/classes/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ export class Vector3 extends Vector {
return this.values[2];
}

cross(vectorOrX, y, z) {
const vec = vectorOrX instanceof Vector ? vectorOrX : new Vector3(vectorOrX, y, z);
cross(...args) {
const vec = new Vector3(...args);
return new this.constructor(this.y * vec.z - this.z * vec.y, this.z * vec.x - this.x * vec.z, this.x * vec.y - this.y * vec.x);
}

Expand Down
6 changes: 6 additions & 0 deletions types/shared/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ declare module "@altv/shared" {
dot(xyz: IVector3): Vector3;
dot(xyz: number): Vector3;

cross(x: number, y: number, z: number): Vector3;
cross(other: Vector3): Vector3;
cross(xyz: [number, number, number]): Vector3;
cross(xyz: IVector3): Vector3;
cross(xyz: number): Vector3;

distanceTo(x: number, y: number, z: number): number;
distanceTo(other: Vector3): number;
distanceTo(xyz: [number, number, number]): number;
Expand Down

0 comments on commit 5ff7b9d

Please sign in to comment.