Skip to content

Commit

Permalink
fix(shared): Add missing Vector.toArray method
Browse files Browse the repository at this point in the history
  • Loading branch information
xLuxy committed Jun 15, 2024
1 parent 63291f8 commit 028d7e1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions shared/js/classes/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export class Vector3 {
return dx * dx + dy * dy + dz * dz;
}

toArray() {
return [this.x, this.y, this.z];
}

toFixed(precision = 4) {
return new Vector3(parseFloat(this.x.toFixed(precision)), parseFloat(this.y.toFixed(precision)), parseFloat(this.z.toFixed(precision)));
}
Expand Down Expand Up @@ -230,6 +234,10 @@ export class Vector2 {
return dx * dx + dy * dy;
}

toArray() {
return [this.x, this.y];
}

toFixed(precision = 4) {
return new Vector2(parseFloat(this.x.toFixed(precision)), parseFloat(this.y.toFixed(precision)));
}
Expand Down

0 comments on commit 028d7e1

Please sign in to comment.