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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hlr

v0.1.1

Published

A TypeScript library for rendering 3D curves as SVG with Hidden Line Removal (HLR) / Hidden Curve Removal (HCR) support. All curves are output as cubic Bezier curves, enabling accurate representation of visible and hidden line segments.

Readme

hlr-svg

A TypeScript library for rendering 3D curves as SVG with Hidden Line Removal (HLR) / Hidden Curve Removal (HCR) support. All curves are output as cubic Bezier curves, enabling accurate representation of visible and hidden line segments.

Features

  • HLR/HCR: Automatically determines which curve segments are visible and renders them as solid/dashed lines
  • Multiple Primitives: Supports Sphere, Cylinder, Cone, BoxAabb, PlaneRect, and Disk
  • Intersection Curves: Computes intersection curves between overlapping primitives
  • Silhouette Generation: Automatically generates silhouette curves for curved surfaces
  • three.js-style API: Familiar API design similar to three.js
  • SVG Output: All curves are output as SVG cubic Bezier paths

Installation

npm install

Quick Start

import { Scene, Camera, SvgRenderer, Sphere, Vec3 } from "hlr-svg";

// Create a scene with primitives
const scene = new Scene();
scene.add(new Sphere("sphere1", new Vec3(0, 0, 0), 1));

// Create a camera
const camera = Camera.from({
  kind: "perspective",
  position: new Vec3(3, 2, 4),
  target: new Vec3(0, 0, 0),
  up: new Vec3(0, 1, 0),
  fovYRad: Math.PI / 4,
  aspect: 16 / 9,
  near: 0.1,
  far: 100,
});

// Render to SVG
const renderer = new SvgRenderer({
  width: 800,
  height: 600,
});

const svg = renderer.render(scene, camera);
console.log(svg);

Supported Primitives

  • Sphere: new Sphere(id, center, radius)
  • Cylinder: new Cylinder(id, base, axis, height, radius, caps)
  • Cone: new Cone(id, apex, axis, height, baseRadius, caps)
  • BoxAabb: new BoxAabb(id, min, max)
  • PlaneRect: new PlaneRect(id, center, normal, u, halfWidth, halfHeight)
  • Disk: new Disk(id, center, normal, radius)

API Overview

Scene

const scene = new Scene();
scene.add(new Sphere("s1", center, radius));
scene.add(new Cylinder("c1", base, axis, height, radius, "both"));

Camera

const camera = Camera.from({
  kind: "perspective",
  position: new Vec3(x, y, z),
  target: new Vec3(x, y, z),
  up: new Vec3(0, 1, 0),
  fovYRad: Math.PI / 4,
  aspect: 16 / 9,
  near: 0.1,
  far: 100,
});

SvgRenderer

const renderer = new SvgRenderer({
  width: 800,
  height: 600,
  background: true,
  style: {
    strokeWidthVisible: 2,
    strokeWidthHidden: 1.5,
    dashArrayHidden: "4 4",
  },
  include: {
    silhouettes: true,
    rims: true,
    borders: true,
    boxEdges: true,
    intersections: true,
  },
});

const svg = renderer.render(scene, camera);

Rendering Options

Include Options

Control which curves are automatically generated:

  • silhouettes: Silhouette curves for spheres, cylinders, and cones
  • rims: Rim circles for cylinders and cones
  • borders: Border outlines for PlaneRect
  • boxEdges: All 12 edges for BoxAabb
  • intersections: Intersection curves between overlapping primitives

HLR Parameters

Fine-tune visibility detection:

renderer.render(scene, camera, {
  hlr: {
    samples: 192,        // Number of samples for visibility detection
    refineIters: 22,     // Bisection refinement iterations
    epsVisible: 2e-4,    // Epsilon for visibility raycasting
    cutEps: 1e-6,        // Epsilon for transition point deduplication
    minSegLenSq: 1e-6,   // Minimum segment length squared
  },
});

Custom Curves

Add your own curves to the scene:

import { lineToCubic3 } from "hlr-svg";

const customCurve = lineToCubic3(
  new Vec3(0, 0, 0),
  new Vec3(1, 1, 1)
);

renderer.render(scene, camera, {
  curves: [customCurve],
});

Build & Development

Build

npm run build

Run Demo

# Build first
npm run build

# Run single demo case
npm run demo

# Run all demo cases
npm run demo:all

Web Demo

# Development server
npm run web:dev

# Build for production
npm run web:build

# Preview production build
npm run web:preview

Architecture

The library is organized into several key modules:

  • core/: User-facing API (Scene, SvgRenderer)
  • scene/: Internal scene representation and raycasting
  • curves/: Cubic Bezier utilities and curve builders
  • hlr/: Hidden line removal logic
  • intersections/: Intersection curve computation
  • svg/: SVG output generation

For detailed design notes, see:

License

Private project.