Hello Lydia,

Yes, PolylinePipeline.scaleToSurface will raise the points of the polyline to the surface if it goes through the globe. It uses the EllipsoidGeodesic Patrick mentioned to find the subpositions.

I just realized that it returns a list of numbers instead of a list of Cartesian3s though. I re-worked the functions you need below so that it returns a list of Cartesian3s instead. Send your original positions to the scaleToSurfaceCartesian function, then use the returned list as your position input when you create a polyline.

function generateCartesianArcCartartesian(p1, p2, granularity, ellipsoid) {

var first = ellipsoid.scaleToGeodeticSurface(p1, scaleFirst);

var last = ellipsoid.scaleToGeodeticSurface(p2, scaleLast);

var separationAngle = Cartesian3.angleBetween(first, last);

var numPoints = Math.ceil(separationAngle/granularity);

var result = ;

var start = ellipsoid.cartesianToCartographic(first, carto1);

var end = ellipsoid.cartesianToCartographic(last, carto2);

ellipsoidGeodesic.setEndPoints(start, end);

var surfaceDistanceBetweenPoints = ellipsoidGeodesic.getSurfaceDistance() / (numPoints);

start.height = 0;

var cart = ellipsoid.cartographicToCartesian(start);

result.push(cart);

for (var i = 1; i < numPoints; i++) {

var carto = ellipsoidGeodesic.interpolateUsingSurfaceDistance(i * surfaceDistanceBetweenPoints, carto2);

cart = ellipsoid.cartographicToCartesian(carto);

result.push(cart);

}

return result;

}

funciton scaleToSurfaceCartesian(positions, granularity, ellipsoid) {

if (!defined(positions)) {

throw new DeveloperError(‘positions is required’);

}

granularity = defaultValue(granularity, CesiumMath.RADIANS_PER_DEGREE);

ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);

var length = positions.length;

var newPositions = ;

for (var i = 0; i < length - 1; i++) {

var p0 = positions[i];

var p1 = positions[i+1];

newPositions = newPositions.concat(generateCartesianArcCartartesian(p0, p1, granularity, ellipsoid));

}

var lastPoint = positions[length-1];

var carto = ellipsoid.cartesianToCartographic(lastPoint, carto1);

carto.height = 0;

var cart = ellipsoid.cartographicToCartesian(carto, cartesian);

newPositions.push(cart);

return newPositions;

};

Best Regards,

Hannah