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

lightmapper-wasm

v0.1.1

Published

Low-level JavaScript and WebAssembly wrapper for ands/lightmapper.

Downloads

243

Readme

lightmapper-wasm

A browser-ready JavaScript/WebAssembly wrapper around ands/lightmapper, a single-header C library for baking lightmaps using your existing WebGL2 renderer.

The original C library is included as a submodule under thirdparty/lightmapper.

Prerequisites

| Requirement | Version | |---|---| | Browser with WebGL2 | Chrome 56+, Firefox 51+, Safari 15+, Edge 79+ | | Emscripten (build only) | 3.x recommended | | CMake (build only) | 3.13+ | | Node.js (dev server) | 18+ |

See WASM_SETUP.md for detailed Emscripten installation and build instructions.

Installation

npm install lightmapper-wasm

Then import in your project:

import { createLightmapperModule } from "lightmapper-wasm";

Build from source

# 1. Ensure Emscripten is on your PATH (see WASM_SETUP.md)
# 2. Configure & compile
npm run configure:wasm
npm run build:wasm
# 3. Serve the demo
npm run serve:demo

Quick Start

import { createLightmapperModule } from "lightmapper-wasm";

// 1. Initialize with an existing WebGL2 canvas
const canvas = document.getElementById("viewport");
const gl = canvas.getContext("webgl2");
const lm = await createLightmapperModule({ canvas, webglContext: gl, autoRegisterEmscriptenContext: true });

// 2. Allocate a lightmap buffer on the WASM heap
const W = 256, H = 256, C = 4;
const floatCount = W * H * C;
const lightmapPtr = lm.allocF32(floatCount);
lm.viewF32(lightmapPtr, floatCount).fill(0);           // clear to black

// 3. Create a lightmapper context
lm.makeBoundContextCurrent();
const ctx = lm.lmCreate(64, 0.001, 100.0, 0, 0, 0, 2, 0.01, 0.0);

// 4. Bind lightmap + geometry
lm.lmSetTargetLightmap(ctx, lightmapPtr, W, H, C);
lm.lmSetGeometry(ctx, 0,
  lm.LM_FLOAT, verticesPtr, strideBytes,
  lm.LM_NONE, 0, 0,
  lm.LM_FLOAT, verticesPtr + 12, strideBytes,          // UV offset = 3 floats × 4 bytes
  indexCount, lm.LM_UNSIGNED_SHORT, indicesPtr);

// 5. Render loop — keep calling lmBegin until it returns false
const bufs = lm.makeBeginFrameBuffers();
while (lm.lmBegin(ctx, bufs.viewportPtr, bufs.viewPtr, bufs.projectionPtr)) {
  const vp   = bufs.readViewport();
  const view = bufs.readViewMatrix();
  const proj = bufs.readProjectionMatrix();

  gl.viewport(vp[0], vp[1], vp[2], vp[3]);
  drawScene(gl, view, proj);                            // your scene draw call
  lm.lmEnd(ctx);
}
bufs.dispose();

// 6. Post-process and read back
const tmpPtr = lm.allocF32(floatCount);
lm.lmImageDilate(lightmapPtr, tmpPtr, W, H, C);
lm.lmImageDilate(tmpPtr, lightmapPtr, W, H, C);
lm.lmImagePower(lightmapPtr, W, H, C, 1.0 / 2.2, 0x7); // gamma correct RGB

const result = lm.copyFromHeap(lightmapPtr, new Float32Array(floatCount));

// 7. Clean up
lm.lmDestroy(ctx);
lm.free(tmpPtr);
lm.free(lightmapPtr);

Documentation

License

See the original lightmapper repository for license details.