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

three.text-atlas

v1.0.0

Published

Text labels for three.js, drawn from a texture atlas of the font made in the browser

Readme

THREE.Text

THREE.Text for three.js: text labels drawn from a texture atlas of the font, made in the browser

Demo

2026 update

Disclaimer: this library is from 2016. three.js still has no text of this kind built in, so it's still useful, but it's a simple one: a single line, no kerning, and it blurs when it gets much bigger than the size the atlas was made at

What three.js ships is different: TextGeometry, in the addons, builds real geometry out of a font converted to JSON, and CSS2DRenderer, also in the addons, positions DOM elements over the scene. For sharp text at any size, outside of three.js, there's troika-three-text.

The library has been rewritten for current three.js. What changed from the 2016 version:

  • it's an ES module, and it needs three.js r155 or later
  • the shaders are part of the library, they used to be script tags in the page
  • all the labels of an atlas share one material, there used to be one per label, each with three arrays of uniforms
  • strings can have any length, the limit was 32 characters
  • the glyphs are measured with the canvas text metrics and packed into an atlas of the right size. They were measured by scanning pixels and drawn in a fixed grid, where wide glyphs overlapped and the last one had no size
  • the origin of a label is at the start of its baseline, it used to be below it
  • the font can also be one that's already loaded in the page, woffSrc is optional
  • labels can have a color, and there's a dispose() for labels and atlases

How to use

Use npm to install it, alongside three.js

npm i three three.text-atlas

and import it in your code

import * as THREE from 'three';
import { FontAtlas, Text, SCALE } from 'three.text-atlas';

It's a plain ES module, so it also works without a bundler as long as an import map resolves three (see examples/index.html).

Create an atlas for a font. It draws the glyphs into a texture once the font has loaded:

const atlas = new FontAtlas( {
  renderer: renderer,
  fontName: 'Permanent Marker',
  size: 140,
  woffSrc: 'url(https://fonts.gstatic.com/s/permanentmarker/v5/9vYsg5VgPHKK8SXYbf3sMupm9E4gBdgiUiSJePew_SQ.woff)'
} );

await atlas.onReady;

size is the size of the font in the atlas, in pixels, 90 by default. Leave woffSrc out to use a font the page already has. The other settings are fontStyle, string with the characters to include, and outline with the width of the black outline, 2 by default.

A callback as second argument works too, atlas.ready tells if it's done, and atlas.canvas is the atlas itself.

Create labels with the atlas, and add their mesh to the scene:

const text = new Text( atlas );
text.set( 'Hello' );
scene.add( text.mesh );

const red = new Text( atlas, { color: 0xff0000 } );

Call set() whenever the text changes, it does nothing if the string is the same. Characters that are not in the atlas leave a space.

A label starts at the origin of its mesh and sits on the baseline. One pixel of the font is 0.001 units, and text.width is in pixels, so to center a label:

text.mesh.position.x = - .5 * text.width * SCALE;

To release them:

text.dispose();
atlas.dispose();

License

MIT licensed

Copyright (C) 2016 Jaume Sanchez Elias, http://www.clicktorelease.com