Implement viewport and test. Distance is now a double.