UNPKG

@jsprismarine/math

Version:
68 lines 1.74 kB
/** * 2D Vector. */ export declare class Vector2 { protected x: number; protected z: number; /** * Returns a Vector2 with 0 on all axis. */ static get ZERO(): Vector2; /** * Create a new `Vector2` instance. * @param {number} x - The X coordinate. * @param {number} z - The Z coordinate. * @example * ```typescript * const vector = new Vector2(10, 20); * ``` */ constructor(x?: number, z?: number); toString(): string; /** * Creates a new Vector2 instance from an object with x and z properties. * @param obj - The object containing x and z properties. * @returns {Vector2} A new Vector2 instance. */ static fromObject({ x, z }: { x: number; z: number; }): Vector2; /** * Set the X coordinate. * @param {number} x - The X coordinate. * @example * ```typescript * await entity.setX(10); * ``` */ setX(x: number): void; /** * Set the Z coordinate. * @param {number} z - The Z coordinate. * @example * ```typescript * await entity.setZ(10); * ``` */ setZ(z: number): void; /** * Get the x coordinate. * @returns {number} The x coordinate's value. */ getX(): number; /** * Get the z coordinate. * @returns {number} The z coordinate's value. */ getZ(): number; floor(): Vector2; trunc(): Vector2; /** * Compare an instance of `Vector3` with another. * @param {Vector2} vector - The `Vector3` to compare to. * @returns {boolean} `true` if they're equal otherwise `false`. */ equals(vector: Vector2): boolean; } //# sourceMappingURL=Vector2.d.ts.map