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 🙏

© 2025 – Pkg Stats / Ryan Hefner

watlas

v1.0.1

Published

[![Build Status](https://github.com/toji/watlas/actions/workflows/build.yml/badge.svg)](https://github.com/toji/watlas/actions/workflows/build.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Downloads

18,486

Readme

watlas

Build Status License: MIT

watlas is a WebAssembly wrapper for xatlas, making is accessible to JavaScript in browsers and node.js. The primary difference between this as and other JS wrappers like xatlas.js is that this wrapper attempts to expose the native API as closely as possible. This makes it potentially harder to use compared to xatlas.js for simple cases but should be more flexible for a wider range of uses.

This wrapper was written with the intent to be used by gltf-transform

Why the name watlas?

Because the much better name of xatlas.js was already taken. :)

The "w" in this case stands for "web", and happens to be right next to "x" in the (english) alphabet.

Library Use

Initialization

You can install it locally via npm and import for node_modules

# Command Line
$> npm install watlas
import * as watlas from 'watlas' // For node.js

import * as watlas from '../node_modules/watlas/dist/watlas.js' // For the browser

Or import the library from a CDN:

// Import from a CDN
import * as watlas from 'https://cdn.jsdelivr.net/npm/watlas'

Whichever way you import it, to begin using the library you need to call watlas.Initialize() and wait on the returned promise before making any other WAtlas calls.

// IMPORANT! Initialize the WASM module prior to calling any API methods.
await watlas.Initialize();

Simple use

// Create an empty atlas
const atlas = new watlas.Atlas();

// Load your mesh data into Typed Arrays
const positions = new Float32Array([ /*...*/ ]);
const indices = new Uint16Array([ /*...*/ ]);

// Add one or more meshes
atlas.addMesh({
  vertexPositionData: positions,
  vertexCount: 256,
  vertexPositionStride: 12, // In bytes
  indexData: indices, // Index format will be determined by Typed Array type
  indexCount: 512,
});

// Call generate on the atlas
atlas.generate(
  {}, // Chart options
  {}  // Pack options
);

// Packed atlas data is not available on the atlas object.
// See below for how to interpret results
console.log(`Atlas size: (${atlas.width}, ${atlas.height})`);

// When finished, manually delete the atlas
atlas.delete();

Tools/Editor integration

// Add one or more meshes
atlas.addMesh({

});

// computeCharts segments meshes into charts and parameterize
atlas.computeCharts({
  maxChartArea: 256
});

// packCharts packs charts into one or more atlases. Can call multiple times
// to tweak options like texel scale and resolution
atlas.packCharts({
  padding: 1,
  bilinear: false,
});

Pack multiple atlases into a single atlas

// Add one or more UV meshes
atlas.addUvMesh({

});

// Call packCharts
atlas.packCharts({
  padding: 1,
  bilinear: false,
});

Using Results

// Loop through each mesh that was part of the atlas.
// (Returned in the order that they were added to the atlas)
for (let i = 0; i < atlas.meshCount; ++i) {
  const mesh = atlas.getMesh(i);

  // Allocate a large enough Uint32Array to hold the updated indicies.
  const indices = new Uint32Array(mesh.indexCount);
  mesh.getIndexArray(indices); // Populates indices with the updated mesh index data

  for (let j = 0; j < mesh.vertexCount; ++j) {
    const vertex = mesh.getVertex(j);
    // UVs are returned in texels, and will need to be normalized for most use cases.
    const u = vertex.uv[0] / atlas.width;
    const v = vertex.uv[1] / atlas.height;

    // xref gives the original vertex index associated with this new vertex.
    // Copy the attributes from the original mesh at that index.
    emitVertex(positions[vertex.xref], normals[vertex.xref], [u, v]);
  }
}

Building

First, make sure emscripten is installed. watlas requires emscripten 4.0.9 or greater to support std::optional fields.

Also ensure that npm is installed, which is packaged with node.js

Then run:

npm install
npm run build

This should produce watlas.js, watlas.wasm, and watlas.d.ts in the dist\ folder.

Note for WSL users

If you are building via Windows Subsystem for Linux (WSL) you may run into the following error message while building:

error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

This can be resolved by running apt install libatomic1 to install the missing library

Testing

After building, you can run the test suite by calling

npm run test

About xatlas

xatlas is a small C++11 library with no external dependencies that generates unique texture coordinates suitable for baking lightmaps or texture painting.

It is an independent fork of thekla_atlas, used by The Witness.

See the xatlas GitHub for more details.