painter = (name, { land }) => {
const projection = d3.geoOrthographic();
const path = d3.geoPath(projection);
let i = 0;
class Worklet {
static get inputProperties() {
return ['--sphere-color', '--rotate'];
}
paint(context, { width, height }, properties) {
console.log("running", i++);
path.context(context);
const rotate = JSON.parse(
properties
.get('--rotate')
.toString()
.trim()
);
projection
.fitExtent([[10, 10], [width - 10, height - 10]], { type: "Sphere" })
.rotate(rotate);
context.fillStyle = properties
.get('--sphere-color')
.toString()
.trim();
context.beginPath();
path({ type: "Sphere" });
context.fill();
context.beginPath();
path(land);
context.fillStyle = "white";
context.fill();
context.beginPath();
path({ type: "Sphere" });
context.stroke();
}
}
globalThis.registerPaint(name, Worklet);
}