model3d = {
const { primitives: P, extrusions: E, transforms: T, booleans: B } = jscad;
const { streets, canals } = model;
const { min, max } = Math;
const block = ([x, y], [dx, dy], [h1, h2]) =>
P.cuboid({ size: [dx, dy, h2 - h1], center: [x, y, (h1 + h2) / 2] });
const wall = ([x1, y1], [x2, y2], width, [h1, h2]) => {
const [dx, dy] = [max(x1, x2) - min(x1, x2), max(y1, y2) - min(y1, y2)];
const center = [(x1 + x2) / 2, (y1 + y2) / 2, (h1 + h2) / 2];
return P.cuboid({ size: [dx + width, dy + width, h2 - h1], center });
};
const streets_ = B.union(
streets.edges.map(([id1, id2]) =>
wall(
streets.positions.get(id1),
streets.positions.get(id2),
0.3,
[0, 0.6]
)
)
);
const canals_ = B.union(
canals.edges.map(([id1, id2]) =>
wall(
canals.positions.get(id1),
canals.positions.get(id2),
0.2,
[-0.2, 0.1]
)
)
);
return B.subtract(block([0, 0], [20, 20], [-0.2, 0.1]), streets_, canals_);
}