A Vector3Tuple [x, y, z] representing the 3D position in meters
Only the position is converted: objects placed far from the origin keep the scale of the origin, and Mercator scale grows towards the poles. At country-level distances that difference becomes noticeable, use the Coordinates component there.
import { coordsToVector3 } from '@wendylabsinc/react-three-map/maplibre';
const origin = { latitude: 51.5074, longitude: -0.1278 }; // London
const point = { latitude: 51.5080, longitude: -0.1270, altitude: 50 };
const position = coordsToVector3(point, origin);
// Returns approximately [55.4, 50, -66.7] (meters from origin)
// Use in a component
<mesh position={position}>
<sphereGeometry args={[10]} />
</mesh>
Converts geographic coordinates to a 3D position vector relative to an origin point.
The resulting Vector3Tuple represents the position in meters where:
The horizontal position is exact in the map's Mercator projection, with the scale of the origin (the same space
<Canvas>renders in), so it lines up with the map at any distance.