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

web-gerber

v1.0.1

Published

PCB Gerber parser, render in three.js or save to svg in browser | 在浏览器中解析PCB Gerber文件,支持渲染到Three.js或保存为svg文件

Readme

WebGerber

Printed circuit board visualization tools for JavaScript, fork from tracespace/tracespace

Install

npm

npm install web-gerber

pnpm

pnpm install web-gerber

yarn

yarn add web-gerber

Usage

1. parse and plot

import { parse, plot } from 'web-gerber'

const gerber_str = "" // load your gerber string from somewhere

const parse_result = parse(gerber_str)
const plot_result = plot(parse_result)

2. render

2.1. Render to svg

Now, you can convert plot_result to svg

Notice: We use syntax-tree/hast-util-to-html convert svg tree to svg in html, you should install this first, such as npm install hast-util-to-html or yarn add hast-util-to-html

import { renderSVG } from 'web-gerber'
import { toHtml } from 'hast-util-to-html' //if you want to convert svg tree to html

const svg_tree = renderSVG(plot_result)

// convert to html and show in html
const html_svg = toHtml(svg_tree)
// show in html
document.getElementById('svg')!.innerHTML = html_svg

full demo is in TEST/src/Svg.vue

2.2. Render in three.js

First, initialization three.js interface,

if you already have three.js interface

// if you already have three.js scene, camera, and render
import { NewRenderByThreeInterface } from 'web-gerber'
const three_pcb_render = NewRenderByThreeInterface(scene,camera,renderer)

or you can use NewRenderByElement quickly start three.js interface

import { NewRenderByElement } from 'web-gerber'

//you should provide dom to render, please refer to three.js doc for details.

const el = document.getElementById('testThreeDom')  // make sure it's width and height!
const parm: RenderInitParams = {
    AddAnimationLoop: true,
    AddAxesHelper: true,
    AddOrbitControls: true,
    AddResizeListener: true,
}
const three_pcb_render = NewRenderByElement(el, parm)

Second, render to three.js object

import { renderThree,defaultColor } from 'web-gerber'

const three_mesh = renderThree(plot_result,defaultColor.BaseBoard, undefined, false)

three_mesh can add to three.js scene by scene.add(three_mesh), but we often need assemble different layers. web-gerber provide assemblyPCBToThreeJS to directly assemble different layers.

// you should render outline, drill, (copper, soldermask, silk) of top and bottom
// top_copper_mesh = renderThree(plot_result_top_copper,defaultColor.Copper, undefined, false)
// btm_copper_mesh = renderThree(plot_result_btm_copper,defaultColor.Copper, undefined, false)
import { DefaultLaminar } from 'web-gerber' //default layer thickness


const pcb_struct = {
	Top: {
		Copper: top_copper_mesh,
		SolidMask: top_mask_mesh,
		Silkscreen: top_silk_mesh
	},
	Btm:{
		Copper: btm_copper_mesh,
		SolidMask: btm_mask_mesh,
		Silkscreen: btm_silk_mesh
	},
	Outline: outline_mesh,
	Drill: drill_mesh
}


assemblyPCBToThreeJS(three_pcb_render.Scene, pcb_struct, DefaultLaminar)

If all goes well, you will see a beautiful PCB in three.js, good luck :)

Worker

For large or complex PCB, the time required for rendering is usually very long, and web pages may become block, resulting in a poor user experience, worker can improved this problem.

WebGerber Support rendering 3D by Worker, You can use by:

import threeWorker from 'web-gerber/worker/runner?worker'
const renderWorker = new threeWorker()

Of course, we support multiple workers:

import threeWorker from 'web-gerber/worker/runner?worker'
const renderWorker1 = new threeWorker()
const renderWorker2 = new threeWorker()
const renderWorker3 = new threeWorker()
...

Now, you can postMessage to worker and receive onmessage from worker !

worker's documentwWait for the update. It will come soon... star this project for support us!