altmp / altv-js-module

JS module for alt:V Multiplayer. Powered by NodeJS & v8
MIT License
55 stars 35 forks source link

Add toFixed to vectors #203

Closed ZackaryH8 closed 1 year ago

ZackaryH8 commented 2 years ago

Description of the problem

Sometimes I don't want a really precise vector and end up using toFixed on each value

Desired solution for the problem

Provide a .toFixed method on Vector2 and Vector3 classes so x, y, z can be truncated

Alternatives you considered

declare module 'alt-shared' {
    export interface Vector3 {
        toFixed(decimals: number): Vector3;
    }
}
import * as alt from 'alt-shared';

alt.Vector3.prototype.toFixed = function (decimals: number = 3): alt.Vector3 {
    return new alt.Vector3(this.x.toFixed(decimals), this.y.toFixed(decimals), this.z.toFixed(decimals));
};

Additional context

No response

Version

No response

Scope

shared

LeonMrBonnie commented 2 years ago

If you have already written the code for it, why don't you just add it yourself and make a PR?

ZackaryH8 commented 2 years ago

Just a reminder for me to add it