header icon

RJ Salvador

Software Engineer
and AEC nerd

sw-jscad

project//June 18, 2025

sw-jscad is a JavaScript library by Salvador Workshop that extends jscad for creating parametric 2D and 3D CAD designs with JavaScript code.

I started writing this library in the start of 2025, and found it to be a great way to design 3D models for my new 3d printer. But more importantly, this project allowed me to learn about developing a library for public consumption. And it gave me a tiny glimpse into the design decisions library designers and maintainers have to make regularly.

sw-jscad demo - gallery

Tech

Key Stats

Core technologies:  npm, 3D Modeling, CAD/CAM Software, Open Source Development
Online viewer: sw-jscad-viewer.netlify.app/
API Docs: salvador-workshop.github.io/sw-jscad/
NPM package: npmjs.com/package/sw-jscad
GitHub: github.com/salvador-workshop/sw-jscad

Design

The toolkit is composed of several packages, arranged in a layered architecture.

sw-jscad design

Core packages

The core packages power everything

PackageDescription
sw-jscadJSCAD library for parametric modelling of architectural components
sw-jscad-familiesDesigns groups of related models
sw-jscad-std-specsDefinitions for building elements and various standards/specs
sw-jscad-uiUX, layouts, etc

Sub packages

The sub packages build larger and more complicated components using the core packages as building blocks.

PackageDescription
sw-jscad-buildersTools and functions for building assemblies
sw-jscad-factoryDoesn’t exist yet. For larger and more complicated assemblies, compared to the builders package

Models & Functions

The library can output 2D and 3D designs of things like:

  • arches (1-pt and 2-pt for now)
  • foils (like trefoils, quatrefoils)
  • walls
  • roofs

and a variety of other functions that make JSCAD modelling easier.

Walls

sw-jscad’s wall builder has several options for base/dado/crown moulding. The dado ornamentation respects changes in thickness between the lower and upper portions of the wall. The height of the thickness change can be specified as well.

sw-jscad demo - wall

Arches, Foils

One-point(circular) and Two-point (gothic) arches

sw-jscad demo - arch

2D and 3D foil designs

sw-jscad demo - foils

Entryways

Entryways combine a wall with an arched opening, in this case a gothic arch. The builder ensures a smooth transition no matter what moulding choices and wall options were made.

sw-jscad demo - entryways

Mesh primitives (panel, cuboid, cylinder)

Panels with configurable mesh pattern:

sw-jscad demo - mesh-panel

Cuboid built with said panels:

sw-jscad demo - mesh-cuboid

Cylinder with similar ideas

sw-jscad demo - mesh-cylinder

Misc

Here I’m designing a pegboard-to-surface mount and something similar for mounting something under a floor joist

sw-jscad demo - models

A more advanced idea - creating joists using dowels:

sw-jscad demo - joists