applyRotation = () => `
// rotations, ported from d3-geo
void applyRotation(in vec3 rotate, inout float lambda, inout float phi) {
float x, y, rho, c, cosphi, z, deltaLambda, deltaPhi, deltaGamma, cosDeltaPhi,
sinDeltaPhi, cosDeltaGamma, sinDeltaGamma, k, circle, proj, a, b;
cosphi = cos(phi);
x = cos(lambda) * cosphi;
y = sin(lambda) * cosphi;
z = sin(phi);
deltaLambda = rotate.x * radians;
deltaPhi = rotate.y * radians;
deltaGamma = rotate.z * radians;
cosDeltaPhi = cos(deltaPhi);
sinDeltaPhi = sin(deltaPhi);
cosDeltaGamma = cos(deltaGamma);
sinDeltaGamma = sin(deltaGamma);
k = z * cosDeltaGamma - y * sinDeltaGamma;
lambda = atan(y * cosDeltaGamma + z * sinDeltaGamma,
x * cosDeltaPhi + k * sinDeltaPhi)
- deltaLambda;
k = k * cosDeltaPhi - x * sinDeltaPhi;
k = clamp(k, -1.0, 1.0); // avoid a hole at the poles
phi = asin(k);
}
`