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

@nleidman/particular

v0.4.0

Published

Particular is a simple library for rendering particle effects. It uses WebGL2 and supports running in workers.

Readme

Particular

Words of caution: this is a work in progress.

Please be aware that some APIs may change, and some functionality may not be implemented yet.

Particular is a small library for rendering particle effects. It targets WebGL2, is published as an ES module, and can run on a main-thread canvas or an OffscreenCanvas in a worker.

Installing

npm install @nleidman/particular

Usage

Engine takes CSS layout size and device pixel ratio; internal resolution is size * pixelRatio. The scene expects a Camera (orthographic or perspective). Emitter accepts EmitterOptions such as orientation: 'billboard' | 'free', optional texture, atlasLayout, modelGeometries, useLighting, and useAlphaBlending.

import {
  Camera,
  Engine,
  Emitter,
  Scene,
  TextureLoader,
  type ParticleBatchOptions,
} from '@nleidman/particular';

const canvas = document.querySelector('canvas') as HTMLCanvasElement;

const engine = new Engine(canvas, {
  size: { x: window.innerWidth, y: window.innerHeight },
  pixelRatio: window.devicePixelRatio || 1,
});

const camera = new Camera(engine, 'orthographic', 1000);
const scene = new Scene({ camera });

const texture = await new TextureLoader(engine).load('/textures/particle_atlas.png');

const emitter = new Emitter(engine, {
  texture,
  orientation: 'billboard',
  atlasLayout: { columns: 4, rows: 4 },
});

scene.add(emitter);
engine.addScene(scene);
engine.start();

const batch: ParticleBatchOptions = {
  lifeTime: 5000,
  count: 200,
  size: 24,
  origin: { x: 400, y: 300 },
  v0: { x: 0, y: -200, z: 0 },
  omega0: 2,
  gravity: { x: 0, y: 400, z: 0 },
  Cd: 0.5,
  Cr: 0.5,
  density: 1.225,
  area: 100,
  mass: 0.01,
  momentOfInertia: 10,
  atlas: { offset: { column: 0, row: 0 } },
  scaleWithAge: 0,
  spawnSize: 0,
};

emitter.emit(batch);

On resize, call engine.resize(cssWidth, cssHeight); the engine refreshes each scene’s camera projection for the new resolution.

Particle batch options

Shape of ParticleBatchOptions (see src/emitter/types.ts in the repo):

export interface ParticleBatchOptions {
  /** Lifetime of a particle batch in **ms**; batch ends after `lifeTime` + `spawnDuration` */
  lifeTime: number;
  /** Number of particles in the batch */
  count: number;
  /** Size of a particle in **pixels** */
  size: number;
  /**
   * Per-axis scale of the particle (applied with size).
   * @default { x: 1, y: 1, z: 1 }
   */
  scale?: { x: number; y: number; z: number };
  /** Origin in **pixels**, relative to the top-left of the canvas */
  origin: { x: number; y: number };
  /** Initial velocity in **pixels/s**. Each particle gets a random velocity from `-v0` to `v0` per axis before bias/spread. */
  v0: { x: number; y: number; z: number };
  /**
   * Velocity bias in fractions of `v0` per axis (shifts the random range).
   * @default { x: 0, y: 0, z: 0 }
   */
  velocityBias?: { x: number; y: number; z: number };
  /**
   * Per-axis fraction of the full velocity range used for random spread (1 = full range, 0 = no spread).
   * @default { x: 1, y: 1, z: 1 }
   */
  velocitySpread?: { x: number; y: number; z: number };
  /**
   * Initial angular velocity in **rad/s**; each particle uses a random value in [-omega0, omega0].
   */
  omega0: number;
  /**
   * If true, each particle gets a random initial rotation; if false, all start at 0.
   * @default false
   */
  randomStartRotation?: boolean;
  /** Gravity in **pixels/s²** */
  gravity: { x: number; y: number; z: number };
  /**
   * Spawn window in **ms** (particles appear over this duration).
   * @default 0
   */
  spawnDuration?: number;
  /** Drag coefficient (fluid model) */
  Cd: number;
  /** Angular drag coefficient (fluid model) */
  Cr: number;
  /** Fluid density in **kg/kpx³** */
  density: number;
  /** Cross-sectional area in **px²** */
  area: number;
  /** Mass in **kg** */
  mass: number;
  /** Moment of inertia in **kg·px²** */
  momentOfInertia: number;
  /**
   * Atlas frame and optional sweep animation.
   * @default { offset: { column: 0, row: 0 } }
   */
  atlas: {
    offset: { column: number; row: number };
    sweep?: { by: 'column' | 'row'; stepTime: number; stepCount: number };
  };
  /**
   * Extra scale factor driven by particle age.
   * @default 0
   */
  scaleWithAge: number;
  /** Diameter of the spawn disk in **pixels** */
  spawnSize: number;
  /**
   * Phong-style material. With a particle texture, Ka and Kd come from the texture; Ks and Ns always come from the batch.
   * RGB in [0, 1]; Ns (shininess) often in ~1–500.
   */
  Ka?: { r: number; g: number; b: number };
  Kd?: { r: number; g: number; b: number };
  Ks?: { r: number; g: number; b: number };
  Ns?: number;
  /**
   * Sway: sideways displacement from simplex noise (amplitude in **pixels**). 0 = off.
   * @default 0
   */
  swayStrength?: number;
  /**
   * Sway: time scale for noise sampling (e.g. age * scale). ~0.04 works well with period-2 tileable noise.
   * @default 0.04
   */
  swayTimeScale?: number;
}

Emitter merges these with defaults and derives drag and angularDrag from the physics fields before drawing.

Demo

From the repository root, run npm run dev to open the Vite demo workspace (click to emit, Tweakpane for parameters).