export class Vector3 { constructor( public x: number = 0, public y: number = 0, public z: number = 0 ) {} static fromArray(arr: number[]): Vector3 { return new Vector3(arr[0], arr[1], arr[2]); } toArray(): [number, number, number] { return [this.x, this.y, this.z]; } add(other: Vector3): Vector3 { return new Vector3(this.x + other.x, this.y + other.y, this.z + other.z); } subtract(other: Vector3): Vector3 { return new Vector3(this.x - other.x, this.y - other.y, this.z - other.z); } multiply(scalar: number): Vector3 { return new Vector3(this.x * scalar, this.y * scalar, this.z * scalar); } length(): number { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } normalize(): Vector3 { const len = this.length(); if (len === 0) return new Vector3(); return this.multiply(1 / len); } distance(other: Vector3): number { return this.subtract(other).length(); } }