export class Vector3 {
    x;
    y;
    z;
    static zero = Object.freeze(new Vector3(0, 0, 0));
    static one = Object.freeze(new Vector3(1, 1, 1));
    static up = Object.freeze(new Vector3(0, 1, 0));
    static right = Object.freeze(new Vector3(1, 0, 0));
    static forward = Object.freeze(new Vector3(0, 0, -1));
    constructor(x = 0, y = 0, z = 0) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    clone() {
        return new Vector3(this.x, this.y, this.z);
    }
    add(v) {
        return new Vector3(this.x + v.x, this.y + v.y, this.z + v.z);
    }
    subtract(v) {
        return new Vector3(this.x - v.x, this.y - v.y, this.z - v.z);
    }
    multiplyScalar(scalar) {
        return new Vector3(this.x * scalar, this.y * scalar, this.z * scalar);
    }
    multiply(v) {
        return new Vector3(this.x * v.x, this.y * v.y, this.z * v.z);
    }
    divide(v) {
        return new Vector3(this.x / v.x, this.y / v.y, this.z / v.z);
    }
    divideScalar(scalar) {
        return new Vector3(this.x / scalar, this.y / scalar, this.z / scalar);
    }
    dot(v) {
        return this.x * v.x + this.y * v.y + this.z * v.z;
    }
    cross(v) {
        return new Vector3(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x);
    }
    lengthSquared() {
        return this.dot(this);
    }
    length() {
        return Math.hypot(this.x, this.y, this.z);
    }
    normalize() {
        const len = this.length();
        return len === 0 ? Vector3.zero.clone() : this.multiplyScalar(1 / len);
    }
    distanceTo(v) {
        return this.subtract(v).length();
    }
    lerp(v, t) {
        return new Vector3(this.x + (v.x - this.x) * t, this.y + (v.y - this.y) * t, this.z + (v.z - this.z) * t);
    }
    transformMatrix4(matrix) {
        return matrix.transformPoint(this);
    }
    rotateByQuaternion(rotation) {
        return rotation.rotateVector(this);
    }
    min(v) {
        return new Vector3(Math.min(this.x, v.x), Math.min(this.y, v.y), Math.min(this.z, v.z));
    }
    max(v) {
        return new Vector3(Math.max(this.x, v.x), Math.max(this.y, v.y), Math.max(this.z, v.z));
    }
    equals(v, epsilon = 1e-10) {
        return Math.abs(this.x - v.x) <= epsilon && Math.abs(this.y - v.y) <= epsilon && Math.abs(this.z - v.z) <= epsilon;
    }
    toArray() {
        return [this.x, this.y, this.z];
    }
}
//# sourceMappingURL=Vector3.js.map