class Vec3 {
  x;
  y;
  z;
  constructor(first, y, z) {
    if (typeof first === "object") {
      this.x = first.x;
      this.y = first.y;
      this.z = first.z;
    } else {
      this.x = first;
      this.y = y ?? 0;
      this.z = z ?? 0;
    }
  }
  /**
   * Adds the given vector to this vector.
   *
   * @param other - The vector to be added.
   * @returns A new vector that is the sum of this vector and the given vector.
   */
  add(other) {
    return new Vec3(this.x + other.x, this.y + other.y, this.z + other.z);
  }
  /**
   * Scales the vector by the given factor.
   *
   * @param factor - The factor by which to scale the vector.
   * @returns A new vector that is the scaled version of the original vector.
   */
  scale(factor) {
    return new Vec3(this.x * factor, this.y * factor, this.z * factor);
  }
};

function toRadians(angle) {
  return angle * (Math.PI / 180);
}
export function getLocalPosition(location, rotation, distance) {
  const yaw = rotation.y;
  const pitch = rotation.x;
  const dx = new Vec3(Math.cos(toRadians(yaw)), 0, Math.sin(toRadians(yaw))).scale(distance.x);
  const dy = new Vec3(Math.sin(toRadians(yaw)) * -Math.sin(toRadians(pitch)), Math.cos(pitch * (Math.PI / 180)), Math.cos(toRadians(yaw)) * Math.sin(toRadians(pitch))).scale(distance.y);
  const dz = new Vec3(-Math.sin(toRadians(yaw)) * Math.cos(toRadians(pitch)), -Math.sin(pitch * (Math.PI / 180)), Math.cos(toRadians(yaw)) * Math.cos(toRadians(pitch))).scale(distance.z);
  return new Vec3(location).add(dx).add(dy).add(dz);
}