Skip to content

Instantly share code, notes, and snippets.

@scyrizales
Created September 30, 2022 00:22
Show Gist options
  • Select an option

  • Save scyrizales/024832e86747b548d1448387c489a4e3 to your computer and use it in GitHub Desktop.

Select an option

Save scyrizales/024832e86747b548d1448387c489a4e3 to your computer and use it in GitHub Desktop.
Transformar coordenadas a esfera en ThreeJS
const latLngToVector3 = (latLng, radius) => {
// TODO: pending to fix the projections
const lat = parseFloat(latLng.lat);
const lng = parseFloat(latLng.lng);
const phi = Math.PI * (lat / 90);
const theta = Math.PI * (- (lng + 180) / 180);
const spherical = new THREE.Spherical(radius || 1, phi, theta);
const vector = new THREE.Vector3();
vector.setFromSpherical(spherical);
return vector;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment