Public
Edited
Nov 13, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
params = ({ start: [0, 0], nbPaths: 70 })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
model3d = {
const { primitives: P, extrusions: E, transforms: T, booleans: B } = jscad;
const { min, max } = Math;
let [xmin, xmax] = [+Infinity, -Infinity];
let [ymin, ymax] = [+Infinity, -Infinity];
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 });
};
return B.union(
model.cells.flatMap((cell) => {
const [x, y] = cell.coords;
const shapes = [...cell.exits].map((path) => {
const { cell1, cell2 } = path;
return wall(cell1.coords, cell2.coords, 0.2, [0, 0.5]);
});
const { type, level } = deco.cells.get(cell);
if (type == "room") {
shapes.push(
B.subtract(
block([x, y], [1.1, 1.1], [0, 1]),
B.union(
block([x, y], [0.9, 0.9], [0.5, 1]),
...[...cell.exits].map((path) => {
const { cell1, cell2 } = path;
const open = deco.paths.get(path) == "open";
return wall(cell1.coords, cell2.coords, open ? 0.9 : 0.2, [
0.5,
open ? 1 : 0.75
]);
})
)
)
);
}
return shapes;
})
);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more