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

flexy-bend

v0.1.0

Published

A Three.js library that bends BufferGeometry along Bezier curves.

Readme

flexy-bend

A Three.js library that bends BufferGeometry along Bezier curves.

Demo

Try the interactive demo →

Install

npm install flexy-bend

Usage

import * as flexy from 'flexy-bend';
import * as THREE from 'three';

const R = 3;
const curve = new THREE.CubicBezierCurve3(
    new THREE.Vector3(R, 0, 0),
    new THREE.Vector3(R, R * 0.55, 0),
    new THREE.Vector3(R * 0.45, R, 0),
    new THREE.Vector3(0, R, 0)
);

// A vector perpendicular to the plane the curve lies on.
// For a curve in the XY plane, this is the Z axis.
const orientation = new THREE.Vector3(0, 0, 1);

flexy.bend({
    THREE,
    curve,
    orientation,
    bufferGeometry: mesh.geometry,
    axis: 'x', // the axis the geometry is elongated along
});

API

bend(options)

Bends a BufferGeometry along a CubicBezierCurve3.

| Option | Type | Required | Description | |---|---|---|---| | THREE | Library | ✓ | Your THREE.js instance | | curve | CubicBezierCurve3 | ✓ | The curve to bend along | | bufferGeometry | BufferGeometry | ✓ | The geometry to deform | | axis | 'x' \| 'y' \| 'z' | ✓ | The axis the geometry is elongated along | | orientation | Vector3 | | A vector perpendicular to the curve's plane | | quaternion | Quaternion | | Alternative to orientation | | preserveDimensions | boolean | | If true, the geometry keeps its original arc-length instead of stretching to fill the whole curve. Defaults to false. |

getPointToFaceNormalMap(options)

Raycasts a uniform grid from a rectangular region onto a mesh surface, returning a hashmap from grid points to { normal, point } pairs on the surface. Used as input for wrap().

wrap(options)

Conforms a geometry to a curved surface by looking up the face normal at each vertex's projected position and rotating the vertex to align with it.


How it works

1. Start with a box geometry

plot

2. Define a curve to bend along

plot

3. Normalize each vertex along the bend axis

Each coordinate on the bend axis is mapped to a parameter t ∈ [0, 1] on the curve. The leftmost vertices map to t = 0, the rightmost to t = 1.

4. Sample tangent lines at each parameter

plot

5. Compute orthogonal vectors

For each tangent, compute a perpendicular vector (shown in purple) using the cross product with the reference normal.

plot

6. Rotate to match the original cross-section angle

The orthogonal is rotated around the tangent axis by the angle atan2(z, y) — the angle the original vertex makes in the cross-section plane.

plot

The resulting rotated vectors:

plot

7. Scale to the original cross-section distance

Each rotated vector is scaled to match the original vertex's distance from the bend axis.

plot

8. Final result

The new vertex position is curvePoint(t) + scaledOrthogonal.

plot

The relationship between the curve and the bent geometry:

plot


Development

npm run dev      # start dev server at localhost:5151
npm run build    # build the library (dist/) and demo site (docs/)