npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jbroll/jscad-fluent

v0.6.1

Published

A fluent interface wrapper around JSCAD's modeling API, providing an intuitive and chainable way to create and manipulate 2D and 3D geometry.

Readme

JSCAD Fluent API

A fluent interface wrapper around JSCAD's modeling API, providing an intuitive and chainable way to create and manipulate 2D and 3D geometry.

Installation

npm install jscad-fluent

Quick Start

import { jf } from 'jscad-fluent';

// Create a simple 3D model
const model = jf.cube({ size: 10 })
  .translate([5, 0, 0])
  .rotate([0, Math.PI/4, 0])
  .setColor([1, 0, 0]);

// Create a complex 2D shape
const logo = jf.circle({ radius: 10 })
  .subtract(
    jf.star({
      vertices: 5,
      outerRadius: 8,
      innerRadius: 4
    })
  )
  .expand(1)
  .setColor([0, 0, 1]);

// Extrude 2D into 3D
const extruded = logo.extrudeLinear({ height: 10 });

Features

  • Fluent interface for all JSCAD operations
  • Strong TypeScript support
  • 2D and 3D primitive creation
  • Boolean operations (union, subtract, intersect)
  • Transformations (translate, rotate, scale)
  • Measurements (area, volume, dimensions)
  • Color support
  • Hull operations
  • Expansion and offset operations

API Reference

2D Primitives

// All primitives return a Geom2Wrapper instance
jf.rectangle({ size: [width, height] })
jf.roundedRectangle({ size: [width, height], roundRadius: number })
jf.circle({ radius: number })
jf.ellipse({ radius: [rx, ry] })
jf.polygon(points: [number, number][])
jf.square({ size: number })
jf.star({ vertices: number, outerRadius: number, innerRadius: number })
jf.triangle({ type: 'SSS' | 'AAS' | 'ASA' | 'SAS' | 'SSA', values: [a, b, c] })

3D Primitives

// All primitives return a Geom3Wrapper instance
jf.cube({ size: number })
jf.cuboid({ size: [width, depth, height] })
jf.sphere({ radius: number })
jf.cylinder({
  radius: number | [start, end] | [[x1, y1], [x2, y2]],  // flexible radius
  height: number,
  outer?: number,   // for hollow cylinders
  inner?: number,   // for hollow cylinders
  wall?: number,    // wall thickness (alternative to inner)
  angle?: [start, end]  // partial arc in radians
})
jf.cylinderElliptic({
  height: number,
  startRadius: [rx, ry],
  endRadius?: [rx, ry]
})
jf.torus({ innerRadius: number, outerRadius: number })
jf.ellipsoid({ radius: [rx, ry, rz] })
jf.geodesicSphere({ radius: number, frequency?: number })
jf.roundedCuboid({ size: [width, depth, height], roundRadius: number })
jf.roundedCylinder({ radius: number, height: number, roundRadius: number })
jf.polyhedron({
  points: [number, number, number][],
  faces: number[][]
})

Common Operations (Both 2D and 3D)

// Transformations
geometry.translate([x, y, z])
geometry.translateX(offset)
geometry.translateY(offset)
geometry.translateZ(offset)
geometry.rotate([x, y, z])
geometry.rotateX(angle)
geometry.rotateY(angle)
geometry.rotateZ(angle)
geometry.scale([x, y, z])
geometry.scaleX(factor)
geometry.scaleY(factor)
geometry.scaleZ(factor)
geometry.mirror([x, y, z])
geometry.mirrorX()
geometry.mirrorY()
geometry.mirrorZ()

// Center operations
geometry.center([x, y, z])
geometry.centerX()
geometry.centerY()
geometry.centerZ()

// Color
geometry.setColor([r, g, b])       // RGB values 0-1
geometry.setColor([r, g, b, a])    // RGBA values 0-1

// Boolean operations (accepts spread args, arrays, or mixed)
geometry.union(other)
geometry.union(a, b, c)
geometry.union([a, b, c])
geometry.subtract(other)
geometry.subtract(a, b, c)
geometry.subtract([a, b, c])
geometry.intersect(other)
geometry.intersect(a, b, c)
geometry.intersect([a, b, c])

// Top-level boolean operations (for combining multiple geometries)
jf.union(a, b, c)
jf.union([a, b, c])
jf.subtract(base, hole1, hole2)
jf.subtract(base, [hole1, hole2])
jf.intersect(a, b, c)
jf.intersect([a, b, c])

// Hull operations
geometry.hull(...others)
geometry.hullChain(...others)

// Expansion
geometry.expand(delta, corners?)    // corners: 'round' | 'edge' | 'chamfer'
geometry.offset(delta)

// Measurements
geometry.measureBoundingBox()
geometry.measureBoundingSphere()
geometry.measureCenter()
geometry.measureDimensions()

// Utility
geometry.validate()

2D-Specific Operations

// Measurements
geometry.measureArea()

// Conversion
geometry.toPoints()      // Returns array of 2D points
geometry.toOutlines()    // Returns array of point arrays

// Extrusion to 3D
geometry.extrudeLinear({ height: number })
geometry.extrudeRotate({ angle: number })

3D-Specific Operations

// Measurements
geometry.measureVolume()

// Conversion
geometry.toPolygons()    // Returns array of polygons with vertices

Utility Functions

// Vector creation
jf.vec2.create()
jf.vec3.create()

// Matrix operations
jf.mat4.create()

// Angle conversion
jf.degToRad(degrees)
jf.radToDeg(radians)

Example: Creating Complex Geometry

const complexShape = jf.cube({ size: 10 })
  .union(
    jf.sphere({ radius: 6 })
      .translate([0, 0, 5])
  )
  .subtract(
    jf.cylinder({ radius: 2, height: 20 })
      .rotate([Math.PI/2, 0, 0])
  )
  .expand(0.5, 'round')
  .setColor([0.7, 0.7, 1]);

License

MIT License - see LICENSE file for details