// src/utils/threeHelpers.js

/**
 * Converts latitude and longitude to 3D Cartesian coordinates on a sphere.
 * @param {number} lat Latitude in degrees.
 * @param {number} lon Longitude in degrees.
 * @param {number} radius Radius of the sphere.
 * @returns {[number, number, number]} An array [x, y, z] representing the 3D coordinates.
 */
export function latLonToCartesian(lat, lon, radius = 1) {
    const phi = (lat * Math.PI) / 180; // Latitude to radians
    const theta = ((lon - 90) * Math.PI) / 180; // Longitude to radians (adjust for orientation in Three.js)

    const x = radius * Math.sin(phi) * Math.cos(theta);
    const y = radius * Math.cos(phi);
    const z = radius * Math.sin(phi) * Math.sin(theta);

    return [x, y, z];
}

// ถ้ามีฟังก์ชันอื่นๆ ที่เกี่ยวข้องกับ Three.js Helpers ก็เพิ่มได้ที่นี่