rock-mod
Version:
Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.
52 lines (51 loc) • 1.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Vector3D = exports.Vector2D = void 0;
class Vector2D {
_x;
_y;
get x() {
return this._x;
}
get y() {
return this._y;
}
constructor(x, y) {
this._x = x;
this._y = y;
}
distanceTo(position) {
return Math.sqrt(this.squaredDistanceTo(position));
}
squaredDistanceTo(position) {
const { x, y } = position;
return (this.x - x) * (this.x - x) + (this.y - y) * (this.y - y);
}
isInRange(position, range) {
const squaredDistance = this.squaredDistanceTo(position);
return squaredDistance <= range * range;
}
}
exports.Vector2D = Vector2D;
class Vector3D extends Vector2D {
_z;
get z() {
return this._z;
}
constructor(x, y, z) {
super(x, y);
this._z = z;
}
distanceTo(position) {
return Math.sqrt(this.squaredDistanceTo(position));
}
squaredDistanceTo(position) {
const { x, y, z } = position;
return (this.x - x) * (this.x - x) + (this.y - y) * (this.y - y) + (this.z - z) * (this.z - z);
}
isInRange(position, range) {
const squaredDistance = this.squaredDistanceTo(position);
return squaredDistance <= range * range;
}
}
exports.Vector3D = Vector3D;