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

geom-distribute

v1.0.0

Published

Distribute points on the faces of a triangle mesh: by count or density, random or Poisson disk, weighted by a per-vertex density, with stable per-face seeds and interpolated vertex attributes.

Readme

geom-distribute

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Distribute points on the faces of a triangle mesh: by count or density, random or Poisson disk, weighted by a per-vertex density, with stable per-face seeds and interpolated vertex attributes.

paypal coinbase twitter bluesky

geom-distribute screenshot

Installation

npm install geom-distribute

Usage

See the example and its source.

import { distribute } from "geom-distribute";
import { sphere } from "primitive-geometry";

const geometry = sphere();

// 1000 points uniformly distributed by area
const points = distribute(geometry, { count: 1000, seed: 1 });
// => { positions, normals, uvs, faceIndices, barycentrics }

// 500 points per unit area, following the faces when the mesh deforms
const dense = distribute(geometry, { density: 500, maxCount: 10000 });

// Poisson disk: exactly 1000 well spaced points
const even = distribute(geometry, { count: 1000, method: "poisson" });

// Poisson disk: points at least 0.05 apart
const spaced = distribute(geometry, {
  density: 2000,
  method: "poisson",
  distanceMin: 0.05,
});

// Per-vertex density: more points towards the top
const weights = geometry.positions
  .filter((_, i) => i % 3 === 1)
  .map((y) => y + 0.5);
const weighted = distribute(geometry, { count: 1000, weights });

// Only positions and normals
const light = distribute(geometry, { attributes: ["normals"] });

API

Modules

Typedefs

geomDistribute

geomDistribute.distribute(geometry, [options]) ⇒ PointGeometry

Distribute points on the faces of a triangle mesh, uniformly by area or weighted by a per-vertex density.

Kind: static method of geomDistribute

| Param | Type | Default | | --------- | ---------------------------------------------------- | --------------- | | geometry | SimplicialComplex | | | [options] | DistributeOptions | {} |

SimplicialComplex : object

Triangle cells over shared positions. Any other Float32Array or number[] property whose length is a multiple of the vertex count is a per-vertex attribute (normals, uvs, vertexColors...), its stride being that multiple.

Kind: global typedef Properties

| Name | Type | Description | | --------- | ----------------------------------------------------- | ----------------------------- | | positions | Float32Array | | | cells | module:primitive-geometry~TypedArrayLike | Flat triangle vertex indices. |

PointGeometry : object

Distributed points and their per-vertex attributes interpolated from the source geometry.

Kind: global typedef Properties

| Name | Type | Description | | ------------ | ------------------------- | ----------------------------------------------- | | positions | Float32Array | | | faceIndices | Uint32Array | Source face of each point. | | barycentrics | Float32Array | Weights of the source face vertices (stride 3). |

DistributeOptions : object

Kind: global typedef Properties

| Name | Type | Default | Description | | -------------- | ------------------------------------------------------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | [count] | module:primitive-geometry~NonNegativeInteger | 1000 | Number of points. | | [density] | number | | Points per unit area, finite and >= 0. Overrides count. Points stay on their face when the mesh deforms. | | [maxCount] | number | Infinity | Upper bound on the number of points in density mode, lowering the density when reached. | | [method] | "random" | "poisson" | "random" | Poisson disk distributions space points evenly: exactly count points, or points at least distanceMin apart in density mode. | | [oversampling] | module:primitive-geometry~PositiveInteger | 5 | Candidates per point in Poisson count mode: more is evener but slower. | | [distanceMin] | number | 0 | Minimum distance between points in Poisson density mode, where weights are 1. | | [weights] | Float32Array | Array.<number> | | Per-vertex density factors, one per vertex: relative in count mode, multiplying density otherwise. Poisson spacing scales with 1 / sqrt(weight). | | [seed] | number | string | 0 | | | [attributes] | Array.<string> | | Per-vertex attributes to interpolate. Defaults to all of them. | | [normalize] | boolean | Array.<string> | true | Attributes renormalized after interpolation, true for normals, tangents and binormals. Only their first three components are normalized. |

License

MIT. See license file.