Skip to main content

Orthographic Projections

Historically technical drawing consisted of a lot of orthographic projections. In some cases it still is a great method of communication for 3D models.

Replicad support projections into a drawing (and therefore a projection as an SVG). This code follows the first angle convention.

And here is what the code looks like.

const { drawProjection, draw } = replicad;

/* This follow the "first angle projection" convention
* https://en.wikipedia.org/wiki/Multiview_orthographic_projection#First-angle_projection
*/
const descriptiveGeom = (shape) => {
return [
{ shape, name: "Shape to project" },
{ shape: drawProjection(shape, "front").visible, name: "Front" },
{ shape: drawProjection(shape, "back").visible, name: "Back" },
{ shape: drawProjection(shape, "top").visible, name: "Top" },
{ shape: drawProjection(shape, "bottom").visible, name: "Bottom" },
{ shape: drawProjection(shape, "left").visible, name: "Left" },
{ shape: drawProjection(shape, "right").visible, name: "Right" },
];
};

const main = () => {
// This shape looks different from every angle
const shape = draw()
.vLine(-10)
.hLine(-5)
.vLine(15)
.customCorner(2)
.hLine(15)
.vLine(-5)
.close()
.sketchOnPlane()
.extrude(10)
.chamfer(5, (e) => e.inPlane("XY", 10).containsPoint([10, 1, 10]));

return descriptiveGeom(shape);
};

Custom perspectives

You can also have nice looking perspectives on your shapes.

const { drawProjection, ProjectionCamera, draw } = replicad;

const prettyProjection = (shape) => {
const bbox = shape.boundingBox;
const center = bbox.center;
const corner = [
bbox.center[0] + bbox.width,
bbox.center[1] - bbox.height,
bbox.center[2] + bbox.depth,
];
const camera = new ProjectionCamera(corner).lookAt(center);
const { visible, hidden } = drawProjection(shape, camera);

return [
{ shape: hidden, strokeType: "dots", name: "Hidden Lines" },
{ shape: visible, name: "Visible Lines" },
];
};

const main = () => {
const shape = draw()
.vLine(-10)
.hLine(-5)
.vLine(15)
.customCorner(2)
.hLine(15)
.vLine(-5)
.close()
.sketchOnPlane()
.extrude(10)
.chamfer(5, (e) => e.inPlane("XY", 10).containsPoint([10, 1, 10]));

return prettyProjection(shape);
};