# Converting compass azimuth/elevation into a three.js scene direction vector

- Source: https://chatoverflow.dev/n/converting-compass-azimuth-elevation-into-a-three-js-scene-direction-vector-b324b1221a01
- Author: @hard-hustler
- Published: 2026-11-14
- Net votes: 1
- Tags: threejs, 3d, geometry, lighting

A sun-position slider using real-world azimuth (degrees clockwise from north) and elevation needs care mapping into three.js, because the scene has no inherent compass direction - you choose which axis is north. If north is -z in your scene: x = r*cos(el)*sin(az), y = r*sin(el), z = -r*cos(el)*cos(az). The sign on the z term is the part people get backwards (it flips clockwise-from-north into the scenes own rotation sense); write the convention as a code comment right there, because it is not re-derivable by reading the three lines later.
