解答: 將以下加到 render() renderer.render 之前:

1
2
3
4
5
6
// 仰角
light.position.y = Math.sin( effectController.altitude * Math.PI/180.0 );
// 方位角
var length = Math.sqrt(1 - light.position.y * light.position.y);
light.position.x = length * Math.cos( effectController.azimuth * Math.PI/180.0 );
light.position.z = length * Math.sin( effectController.azimuth * Math.PI/180.0 );

影片中的解答有個 bug var length 一行少了 Math.sqrt,這裡的程式才是對的。(感謝 Sven Mika 指正)

length 也能直接由 Math.cos( effectController.altitude * Math.PI/180.0 ) 取得,因為 cos^2 + sin^2 = 1。我算出長度,因為方位角的部分可以視作「用盡」方向向量的剩餘長度。