diff --git a/shared/js/classes/vector.js b/shared/js/classes/vector.js index 557274c62..88f925e80 100644 --- a/shared/js/classes/vector.js +++ b/shared/js/classes/vector.js @@ -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))); } @@ -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))); }