I am trying to detect where a polyline intersects with the terrain on the Earth. I have a polyline that begins at some point in the air and is drawn towards the Earth at a certain angle. Right now I am calculating the end point just using a set distance, so I have a start and endPoint. I want to detect where this polyline first hits the Earth’s surface and stop drawing it at that point. For example, if there is a tall mountain, I don’t want the line to continue on the other side of the mountain. I’ve tried a few different approaches using IntersectionTests, specifically the grazingAltitudeLocation and rayEllipsoid but have not had any luck. I have been creating a ray with the start and end points of my polyline and then using the viewer.scene.globe.ellipsoid as the ellipsoid in the functions. I keep getting the starting point as the intersection point. Does anyone have any idea what I am doing wrong, or suggestions on a different way to do this? Any help would be greatly appreciated. Thanks.