Created
September 30, 2022 00:22
-
-
Save scyrizales/024832e86747b548d1448387c489a4e3 to your computer and use it in GitHub Desktop.
Transformar coordenadas a esfera en ThreeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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