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

threejs-offset

v1.0.0

Published

Offset meshes with [three.js](https://threejs.org/) library

Downloads

181

Readme

Offset with three.js

Create an offset set of points or an offset mesh from an STL file using the three.js library.

Demo

https://threejs-offset.netlify.app/

Offset

Table of Contents

Installation

npm install threejs-offset

or

yarn add threejs-offset

Usage

This library provides two algorithms for offsetting STL geometry and one helper to build a mesh:

  • processGeometry → offset points
  • createOffsetMesh → offset a full mesh
  • createMeshFromObject → convert an offset mesh object into a Three.js Mesh

Offset a mesh

import { createOffsetMesh, createMeshFromObject } from "threejs-offset"

// Example: parse STL data and apply an offset
const stlData = "... your STL file contents ..."
const offset = 2.0

// Create an offset mesh object
const objects = createOffsetMesh(stlData, offset)

// Convert the object into a Three.js Mesh
const mesh = createMeshFromObject(objects)
scene.add(mesh)

Offset geometry points

import { STLLoader } from "three/examples/jsm/loaders/STLLoader.js";
import { processGeometry } from "threejs-offset";

// If you have an STL file (ArrayBuffer):
const geometry = new STLLoader().parse(arrayBuffer); // THREE.BufferGeometry
const offset = 2;

// Ensure normals are present (STLLoader usually provides them; otherwise compute)
if (!geometry.attributes.normal) geometry.computeVertexNormals?.();

const points = processGeometry(geometry, offset); // returns THREE.Points
scene.add(points);

Notes

  • processGeometry returns a THREE.Points instance with material PointsMaterial({ color: 0xff0000, size: 0.7 }) and name = "offset".

  • createOffsetMesh expects an ASCII STL string (not a BufferGeometry). In practice the workflow in the demo is: export a mesh to ASCII (via STLExporter), call createOffsetMesh, then await createMeshFromObject(...).

  • If your geometry lacks normals, call geometry.computeVertexNormals() before using processGeometry.

How it works

The library provides two algorithms:

  • Point offset – creates a new set of vertices displaced by the given offset.
  • Mesh offset – recalculates faces, normals, and vertices to generate a new offset mesh.

The meshed offset is still experimental: results are not perfect, but it’s a good starting point for further refinement.

Limitations

  • Performance may degrade with very large meshes.
  • Some geometries (e.g. spheres) are not handled correctly yet.
  • For heavy processing, consider moving parts of the algorithm (offsetObjectHash, hashTable) to a Node.js backend.

Development

If you want to start the application locally:

  1. Clone the project git clone [email protected]:AngyDev/threejs-offset.git
  2. With your terminal go to the folder where you cloned the project
  3. Run the command npm install to install the project's dependencies
  4. Run the command npm run build that creates the dist folder
  5. Run the server with the command npm run start
  6. If all is correct the browser will be open to the localhost:9000 url

Contributing

Contributions are welcome! If you have suggestions or bug reports, please open an issue.