I want to place 3d objects to a sphere(planet).
I have the real latitude/longitude coordinates to which I want to place my 3d objects, but I need their babylonJS Vector3 representation. How can I do that?
I think there are also many other people looking at a solution to this problem.
I was unable to find any demo/code to convert both ways:
babylonJS coordinates of a point at a sphere to latitude/longitude(real world GPS coordinates)
Basically I need an implementation to LocationService interface.
I think I need to pass the mesh or the radius of the 3d object.
i could post you a online version of this function at work in an art piece ( code not executing in runtime , was used to build the model and animations. Anyway it i from a competing 3D web solution (sketchfab) so I dont think I should place the link in here.
var paris = {
lat: 48.864716,
lon: 2.349014
}
console.log(paris);
var parisSpherical = {
lat: THREE.Math.degToRad( 90 - paris.lat ),
lon: THREE.Math.degToRad( paris.lon )
}
console.log(parisSpherical);
var radius = 10;
var parisVector = new THREE.Vector3().setFromSphericalCoords( radius, parisSpherical.lat, parisSpherical.lon);
// check we did it correctly
var spherical = new THREE.Spherical().setFromVector3(parisVector);
console.log(spherical);