Skip to content

Instantly share code, notes, and snippets.

@onedayitwillmake
Created May 5, 2011 18:06
Show Gist options
  • Save onedayitwillmake/957548 to your computer and use it in GitHub Desktop.
Save onedayitwillmake/957548 to your computer and use it in GitHub Desktop.
Globe camera rotation
function render() {
zoom(curZoomSpeed);
rotation.x += (target.x - rotation.x) * 0.1;
rotation.y += (target.y - rotation.y) * 0.1;
distance += (distanceTarget - distance) * 0.3;
camera.position.x = distance * Math.sin(rotation.x) * Math.cos(rotation.y);
camera.position.y = distance * Math.sin(rotation.y);
camera.position.z = distance * Math.cos(rotation.x) * Math.cos(rotation.y);
vector.copy(camera.position);
renderer.clear();
renderer.render(scene, camera);
renderer.render(sceneAtmosphere, camera);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment