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

@pmndrs/vdb

v0.2.0

Published

Sparse NanoVDB volumes on WebGPU: engine-free WGSL core, pure-TS CPU tools, three.js adapter

Readme

@pmndrs/vdb

Sparse NanoVDB volumes on WebGPU: an engine-free WGSL core with a compute froxel volume renderer, level-set and point passes, pure-TypeScript CPU tools and a thin three.js adapter. One package, three subpaths.

Docs · Examples · GitHub · Changelog

| Import | What it is | Needs a GPU / three? | |---|---|---| | @pmndrs/vdb | the engine-free WebGPU core: VDBGridPool, the generated vdb* WGSL module (vdbModuleWgsl), GPU compute tools, the froxel renderer (vdbCreateFrameRenderer), volume sources (vdbSparseSource, vdbDenseSource), level-set and point passes, VDBSequence | WebGPU, no engine | | @pmndrs/vdb/tools | CPU side: .nvdb and .wvdb read/write, CPU reads (vdbReadValueCpu, vdbSampleTrilinearCpu), .vdb parser, NanoVDB builder, quantizer, resampler | no | | @pmndrs/vdb/three | the three.js adapter: VDBGridNode (a pool in three's node system), VDBVolumeMaterial, VDBFrameVolume / VDBFrameRenderer (the core's froxel renderer on three's device), VDBLevelSetMaterial / VDBLevelSetPhysicalMaterial, VDBPoints, compute utilities | three (optional peer, >=0.187.0 <0.188.0) | | @pmndrs/vdb/pnanovdb.wgsl | the raw WGSL text (use ?raw in Vite) | no |

npm install @pmndrs/vdb          # core + tools
npm install @pmndrs/vdb three    # to use @pmndrs/vdb/three

three is an optional peer dependency (r187 only). @webgpu/types and fflate are regular dependencies. core and tools never import three.

Coming from 0.1? 0.2.0 moved the froxel renderer into the core, dropped the Gpu suffix from the core's names, added Cpu to the tools' CPU readers and renamed several @pmndrs/vdb/three names; a few defaults change images (ambientOcclusion and occlusion are on, 'neural' uses our own weights): Migrating from 0.1 to 0.2 and the changelog.

@pmndrs/vdb (core) and the raw WGSL module

The engine-free WebGPU layer: VDBGridPool (NanoVDB grids in one storage buffer on the host's GPUDevice), the generated vdb* WGSL module for reading, sampling and marching them (vdbModuleWgsl), GPU compute tools, and since 0.2.0 the froxel volume renderer, its volume sources and the level-set and point passes. It knows nothing about three.js or any other engine. Loading .nvdb files is in @pmndrs/vdb/tools (NvdbFile).

The froxel renderer on raw WebGPU (0.2.0)

vdbCreateFrameRenderer(device) (VDBFrameRenderer) renders volumes through a froxel grid as WGSL compute kernels: 'volume' or 'frame' lighting, temporal accumulation, phase functions (including Lorenz-Mie), multiple scattering, spectral media, an environment, volume shadow maps for your meshes (volume → mesh), your depth maps shadowing the volumes (mesh → volume) and an emission light. It takes your GPUDevice, records into your encoder (update(encoder, input), then render(encoder, targets) or vdbFrameIntegrateWgsl in your own pass), frees only what it made and never submits. Sources: vdbSparseSource (every grid of a VDBGridPool, with LOD) and vdbDenseSource (.wvdb textures). vdbCreateLevelSetPass and vdbCreatePointPass draw level sets and points into your passes. Settings out of the device's range (shadowResolution, shadow map sizes) clamp with a one-time warning. multipleScattering defaults to 'neural' (our trained network, K6.N, on the core's EXPERIMENTAL generic MLP). Demo 17 is a full raw-WebGPU page; see docs/site/core/rendering-without-three.mdx.

Majorants and the lean reader (0.2.0)

For delta and ratio tracking, vdbModuleWgsl({ profile: 'majorant' }) adds vdbMajorantInit / vdbMajorantNext: a walk of piecewise-constant density bounds along a ray, over brick bounds built on the CPU (vdbBrickMajorant, @pmndrs/vdb/tools) or on the GPU (pool.buildMajorant(id)). reader: 'lean' generates a compact reader with the same API and values (about a fifth of the size for Float read). See docs/site/core/wgsl-module.mdx.

What's in the box

  • vendor/pnanovdb.wgsl — a WGSL module with the NanoVDB root -> upper -> lower -> leaf tree traversal, HDDA ray marching, and Float/Fp4/Fp8/Fp16/FpN/Half value decoders. Import it as raw text (?raw in Vite, or read the file yourself) and splice it into your own shader.
  • NvdbFile (@pmndrs/vdb/tools) — parses a .nvdb file (header + per-grid metadata + grid images), handling the NONE, ZIP and BLOSC codecs.
  • A pure-TypeScript CPU reference (@pmndrs/vdb/tools: vdbReadValueCpu, vdbReadValueF32Cpu, vdbSampleTrilinearCpu) — the exact same tree descent as the WGSL module, so you can sanity-check GPU results or read voxels with no GPU at all (Node, workers, tests).

Quickstart: load a file and read a voxel

import { NvdbFile, vdbReadValueCpu } from "@pmndrs/vdb/tools";

const file = await NvdbFile.fromURL("/fixtures/sphere_fog_float.nvdb");
const gridImage = file.gridImage(0); // flat Uint32Array — the grid, as-is on disk
const meta = file.grids[0]!;
console.log(meta.name, meta.gridType, meta.voxelCount);

const { value, active } = vdbReadValueCpu(gridImage, [12, 4, -3]);

gridImage is a zero-copy view into the file's buffer when possible (file.isGridImageZeroCopy(0) tells you which) — upload it straight into a GPU storage buffer, no reshaping needed.

Loading the raw WGSL module

import pnanovdbSource from "@pmndrs/vdb/pnanovdb.wgsl?raw"; // Vite/bundler `?raw` import
// or, outside a bundler: fetch(import.meta.resolve("@pmndrs/vdb/pnanovdb.wgsl"))

pnanovdbSource is the library's text, unmodified. It's a genuine C-style library, not a drop-in snippet: its reads all bottom out in one function, pnanovdb_buf_read_uint32, that expects the consumer to declare a module-scope var<storage, read> nanovdb_buffer: array<u32> binding (see vendor/VENDOR.md for the exact contract) — plus pnanovdb_buf_t/address plumbing and (for point-sampling) an accessor struct. You rarely need it directly: the core's generator (vdbModuleWgsl) builds a pool-aware vdb* module from it. Integrations to copy from instead of re-deriving the binding:

  • examples/src/demos/08-webgpu-smoke: raw WebGPU on the core (VDBGridPool + vdbModuleWgsl), no engine.
  • @pmndrs/vdb/three (src/three): VDBGridNode binds the pool through three's node system (below).
  • examples/src/demos/03-gpu-read is a from-scratch, heavily-commented raw-WebGPU walkthrough (no three.js) that hand-derives a FLOAT-only traversal function equivalent to this library's, teaching the byte layout end to end.

Supported grid types / codecs

| Grid type | Read (WGSL + CPU) | Notes | |---|---|---| | Float | yes | lossless, 4 bytes/voxel | | Fp8 | yes | per-leaf min/quantum, 1 byte/voxel | | FpN | yes | per-leaf variable bit-width (oracle-matched to native) | | Fp4, Fp16 | yes | per-leaf min/quantum | | Half | yes | raw IEEE binary16, 2 bytes/voxel (NanoVDB 13.2+; matches native v14) | | other GridTypes | rejected | NvdbFile throws a clear "unsupported grid type" error |

| File codec | Support | |---|---| | NONE | yes | | ZIP (zlib, via fflate) | read and write (writeNvdb(images, { codec: 'zip' })) | | BLOSC | read: NanoVDB's LZ4 frames (nanovdb_convert -b/--blosc, any chunking) and NVIDIA Warp's BloscLZ frames. Write: writeNvdb(images, { codec: 'blosc' }), LZ4 frames byte-identical to native NanoVDB v14's (0.2.0) |

The vendoring story

The WGSL module is not written from scratch: per decision D2, it's vendored as a pinned, audited fork of emcfarlane/webgpu-nanovdb's pnanovdb.wgsl — Apache-2.0, NOTICE preserved, every local change logged in-tree. We're prepared to diverge permanently and happy to upstream fixes if the author engages. Full pin/hash/diff-log details: vendor/VENDOR.md.

@pmndrs/vdb/tools

The CPU half: parse .vdb containers, build NanoVDB grid images (from a dense array or straight from a parsed .vdb), quantize to Fp4/Fp8/Fp16/FpN/Half, apply affine transforms, inspect memory layout, and write .nvdb files — all pure TypeScript, no WASM (the one runtime dependency is fflate for zlib; decision D3). WASM stays an optional escalation rung, adopted only on demonstrated need — nothing in this package requires it.

Quickstart: the demo 07 pipeline

The full authoring round-trip — generate/obtain voxels, build a NanoVDB grid, optionally quantize, write a real .nvdb file — trimmed from examples/src/demos/07-builder:

import { vdbBuildFromDenseDetailed, vdbQuantize, writeNvdb } from "@pmndrs/vdb/tools";

const dim = 32;
const values = new Float32Array(dim * dim * dim); // fill with your density field
// ... write nonzero values into `values` at your active voxels ...

const built = vdbBuildFromDenseDetailed(values, [dim, dim, dim], {
  gridName: "my_grid",
  background: 0,
});
// built: { image: Uint32Array, voxelCount, indexBBox, worldBBox, voxelSize, nodeCounts }

const fp8Image = vdbQuantize(built.image, "fp8"); // or "fpn"; per-leaf min/quantum, native-exact rounding

const fileBuffer = writeNvdb([fp8Image]); // ArrayBuffer — a real NanoVDB2 file, ready to save/upload

fileBuffer round-trips through NvdbFile.fromArrayBuffer byte-for-byte (that loader is this subpath's read path, see above).

Quickstart: parse a real .vdb and build NanoVDB from it

The drop-in-a-file pipeline, trimmed from examples/src/demos/06-explorer:

import { parseVdb, buildFromVdbDetailed, vdbInspect } from "@pmndrs/vdb/tools";

const buffer = await fetch("/fixtures/vdb-samples/utahteapot.vdb").then((r) => r.arrayBuffer());
const vdbFile = parseVdb(buffer); // { fileVersion, grids: VdbGrid[], descriptors: VdbGridDescriptor[] }

const built = buildFromVdbDetailed(vdbFile.grids[0]!); // streams leaves, no dense allocation
const report = vdbInspect(built.image);
console.log(report.nodeCounts, report.memoryBreakdown);

buildFromVdb/buildFromVdbDetailed (float grids) stream the parser's leaves straight into the NanoVDB serializer (proven on a 7M-voxel teapot with no dense array), carrying the .vdb file's uniform scale+translate transform into the NanoVDB Map.

API surface

| Function | What it does | |---|---| | parseVdb(buffer, { select }?) | Reads a .vdb container (file version 225 or older): float, half (as float), vec3 and point grids, 5-4-3 tree, uncompressed, zlib or Blosc, active tiles. select(descriptor) picks which grids to decode; descriptors lists every grid, an unsupported one reported rather than thrown | | vdbBuildFromDense / vdbBuildFromDenseDetailed | Dense Float32Array -> NanoVDB FLOAT grid image | | vdbBuildFromLeavesDetailed | Lower-level: build from an already-leaf-shaped source (what buildFromVdb and vdbQuantize are built on) | | buildFromVdb / buildFromVdbDetailed | Parsed .vdb grid -> NanoVDB FLOAT grid image, leaf-streamed | | vdbQuantize / vdbQuantizeDetailed | FLOAT grid image -> Fp4/Fp8/Fp16/FpN (per-leaf min/quantum; FpN bit-width picked per leaf) or Half (binary16) | | vdbTransform | Metadata-only affine edit (uniform scale + translate) on a copy; throws with a GPU-resample pointer for rotation/shear (D6) | | vdbTreeNodes | Generator over a scalar grid image's tree: leaves (origin, active voxel count), tiles (level, origin, size, value, active) and, on request, the upper and lower nodes | | vdbInspect | Node counts + memory-by-section breakdown, summing to the grid's total byte size | | writeNvdb | Serializes one or more grid images into a .nvdb file ArrayBuffer (NanoVDB2, io::Segment layout; codec: 'zip' or 'blosc' for NanoVDB's codecs; segments: 'per-grid' writes one segment per grid, which native io::readGrid(file, n) needs) | | vdbBakeCoarseFirst | Coarse-first .nvdb: a small preview grid (<name>.lod48, box, FpN) then the full grid, ZIP by default | | vdbLevelSetMesh / vdbLevelSetMeshChunks | A triangle mesh of a level set's zero surface (surface nets over the sparse leaves), whole or in chunks, for collision and export | | vdbLevelSetMeshDecimate | Fewer triangles for such a mesh or chunk: edge collapses kept within error voxels of the grid's iso surface (checked at sample points on each changed triangle); seams survive | | vdbBrickMajorant / vdbBrickAtlas | Brick bounds for delta and ratio tracking (pool.add(image, { majorant }), the majorant WGSL profile), and pmndrs/pathtracer's sparse brick atlas | | vdbPointRenderData | Positions, colours and other attributes of a parsed point grid as flat arrays for VDBPoints or the core point pass | | NvdbStreamReader / readNvdbStream | Reads a .nvdb from pushed bytes or a stream, emitting each grid as soon as its data is complete; hostile-input checks before allocation | | NvdbFile | Reads a .nvdb held in memory or fetched (fromArrayBuffer / fromURL); there is no separate readNvdb |

Supported .vdb subset

| | Support | |---|---| | Grid type | float, half (HalfGrid, OpenVDB 13+; read as float, gridType keeps Tree_half_5_4_3), vec3 (Vec3f/Vec3d/Vec3i) and point data grids | | Tree configuration | 5-4-3 (OpenVDB's default) | | Compression | none, zlib, Blosc (LZ4, BloscLZ and zlib) | | Half-float leaf storage | yes | | File version | up to 225 (what OpenVDB v14 writes); a newer one throws VDBUnsupportedError | | Transform | uniform scale + translate (affine Map); non-uniform/rotated throws on vdbTransform(), parses fine on parseVdb()/buildFromVdb() |

Native parity

Every function above is validated byte/value-wise against real nanovdb_convert/OpenVDB output on the project's fixture corpus (four openvdb.org samples + primitives). The one anchor that needs a native machine to close out (this package's numbers already match at every tested coordinate) is tracked in docs/archive/handoffs/PHASE-5.md — see that doc for the full parity checklist and known semantic edge cases (root background vs. near-field tile fill, active-tile compression, CRC).

@pmndrs/vdb/three

The three.js adapter over the engine-free core (D8), on three r187 (D23). The grids live in a VDBGridPool on the renderer's GPUDevice; VDBGridNode puts that pool into three's node system without copying it (three binds the pool's own buffer); VDBVolumeMaterial raymarches one pooled grid, and VDBSequence (the core's, re-exported) plays frames into one pool id.

Quickstart: render a cloud

This mirrors examples/src/demos/02-cloud, trimmed to the essentials (no camera controls, no live uniforms):

import * as THREE from "three/webgpu";
import { VDBGridPool } from "@pmndrs/vdb";
import { NvdbFile } from "@pmndrs/vdb/tools";
import { VDBGridNode, VDBVolumeMaterial, getDevice, vdbProxyGeometry } from "@pmndrs/vdb/three";

// The host owns the device: the pool's limits, passed to the renderer so the
// pool outlives renderer.dispose() (a renderer that made its own device destroys it).
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter!.requestDevice({ requiredLimits: VDBGridPool.requiredLimits(adapter!) });
const renderer = new THREE.WebGPURenderer({ device, canvas });
await renderer.init();

const file = await NvdbFile.fromURL("/fixtures/wdas_cloud_quarter_fp8.nvdb");
const pool = await VDBGridPool.create(getDevice(renderer));
const id = pool.add(file.gridImage(0));
pool.flush(); // writes the grid (or record pool.update(encoder) into your own encoder)

// One VDBGridNode per pool, renderer and shader (one WGSL module per shader).
// The material needs the support-box ray clip helper.
const grids = new VDBGridNode(renderer, pool, { helpers: ["rayClipSupport"] });
const material = new VDBVolumeMaterial(renderer, grids, id); // the defaults are sized to the grid
const scene = new THREE.Scene();
scene.add(new THREE.Mesh(vdbProxyGeometry(pool.info(id)), material));

// Every frame: the pool's update first (submitted), then the node, then three.
pool.flush();
grids.update(); // rebinds only when a growth replaced pool.buffer
await renderer.renderAsync(scene, camera);
  • VDBGridNode(renderer, pool, { types?, profile?, sampler?, isActive?, outside?, helpers?, name? }): the module options minus the binding (three assigns it). types defaults to the pool's types now; pass every type you will add (or VDB_ALL_SCALAR_TYPES) when the pool fills later. TSL helpers: vdbSample(grids, id, position, { space: 'world' | 'index' }) and vdbReadValue(grids, id, ijk); or call the WGSL API from your own wgslFn(src, [grids.module]) (demo 01 does both). A node binds through the renderer it was made with: a shader another renderer builds, or a shader holding a second node's module, throws VDB_BAD_OPTION (make one node per renderer; read every grid of a shader through one node, by id). The first node on a renderer self-tests three's attribute internals before the pool's buffer reaches three (VDB_ENGINE_MISMATCH if three would destroy it); a three other than r187 warns once, and so does a renderer that made its own device (its dispose() destroys the pool's buffer).
  • VDBVolumeMaterial(renderer, grids, gridId, params): needs a node with profile sample or march and helpers: ['rayClipSupport']. The march is one wgslFn over the public API: world ray to index space through the pool record (pool.setTransform instances work), clipped to the trilinear support box, fixed-step density with vdbSample, Henyey-Greenstein sun with a shadow march, ambient, and a per-fragment sample budget. The defaults draw a lit volume on any grid: opticalDepth (6) is the optical depth across the grid's longest index side at its mean density (densityReference, read from pool.info(id).rootAverage at each render), and the shadow ray spans shadowReach (0.3) of that side. densityScale > 0 is the extinction per index voxel instead (0.1's look: { densityScale: 40, sunIntensity: 3, shadowReach: 0 }). Every tunable is a live uniform (material.opticalDepth.value = 10, material.stepSize.value, maxSteps, sunDirection, sunColor, sunIntensity, anisotropy, shadowSteps, shadowDensity, shadowReach, ambient, jitter); gridId is a uint uniform when given as a number, so material.gridId.value = other switches grids without a rebuild (give the mesh a new vdbProxyGeometry for the other grid, and after pool.setTransform). Caps (maxStepsCap, shadowStepsCap, sampleBudgetCap) are compiled in. The march runs in index space: stepSize is in index voxels and the density is relative to the index box (or per index voxel with densityScale), so scaling a grid with setTransform changes its size on screen, not its opacity. Perspective cameras only. grids must come from the same renderer.
  • vdbProxyGeometry(pool.info(id), { pad? }): the world box to put the material on (add the mesh with an identity transform). pad: 1 also covers the min-side half voxel of the trilinear support.
  • getDevice(renderer), getGPUTexture(renderer, texture): the raw WebGPU handles, as in @pmndrs/upscaler and @pmndrs/denoiser.
  • Gone since v1: NanoVDBGrid (use pool.info(id) and vdbProxyGeometry), NanoVDBVolumeMaterial (use VDBVolumeMaterial), NanoVDBSequence (use VDBSequence), assembleVolumeWgsl/rewriteBufferGlobal, and the createVolumeRenderer bootstrap with computeRequiredLimits/nextPow2 (create the device yourself with VDBGridPool.requiredLimits(adapter), as in the quickstart).

Compute utilities

Compute passes over a grid in a VDBGridPool (K2.3). The engine-free core records into your encoder and hands back a readback you resolve after submitting; the three wrappers take the renderer and return promises:

import { VDBGridPool, vdbGridStats, vdbDecodeToAtlas, vdbApplyValueTransform } from "@pmndrs/vdb";

const id = pool.add(image);
pool.update(encoder); // or pool.flush()
const stats = vdbGridStats(device, pool, id, { encoder, histogramBins: 256 });
const atlas = vdbDecodeToAtlas(device, pool, id, { encoder, maxDim: 128, format: "uint8" });
device.queue.submit([encoder.finish()]);
// With your encoder, say it was submitted before reading (read() earlier rejects with VDB_BAD_OPTION):
await stats.submitted().read();  // { min, max, mean, histogram, activeVoxelCount, usedAtomicFastPath, range }
await atlas.submitted().read();  // { data: Uint8Array | Float32Array, dims, range }; atlas.buffer is the raw f32 GPU output

// Per-voxel edits run on the CPU (the pool is read-only to shaders) and are staged with pool.replace:
vdbApplyValueTransform(pool, id, image, "double"); // or (v) => v * 2; Float grids only
import { vdbGridStats, vdbDecodeToAtlas } from "@pmndrs/vdb/three";

const stats = await vdbGridStats(renderer, pool, id);
const { data, dims, range, texture } = await vdbDecodeToAtlas(renderer, pool, id, { maxDim: 128 }); // texture: Data3DTexture

The three wrappers submit their own encoder. The value transform has no three wrapper: call the core vdbApplyValueTransform.

Each tool frees only the buffers it allocated (in read() or dispose()). vdbGridStats bins over the grid's root min/max statistics (a grid with a negative root min takes the dump path, 8 B per bbox voxel, and is refused up front when that exceeds the device's buffer limits); vdbDecodeToAtlas normalizes to them by default. Atlas cell i of an axis with n cells over [min, max] samples index position min + (i + 0.5) * (max - min + 1) / n - 0.5, so at full resolution cell i is voxel min + i (the last cell is max); the texture spans the voxel-centred box [min - 0.5, max + 0.5]. vdbApplyValueTransform rewrites leaf values (not tiles) and does not recompute the image's statistics. CPU versions live in @pmndrs/vdb/tools (vdbGridStatsCpu, vdbDecodeToAtlasCpu). See examples/src/demos/04-atlas-fallback for the atlas fallback path through a stock Data3DTexture.

Coarse-first loading: vdbStreamCoarseFirst

A file baked with vdbBakeCoarseFirst (@pmndrs/vdb/tools) holds a ~12 KiB preview grid before the full grid (design note). vdbStreamCoarseFirst reads the response body as it arrives, adds the preview to the pool with the full grid's size reserved, and replaces it in place when the full grid is in:

import { vdbStreamCoarseFirst } from "@pmndrs/vdb/three";

const { id } = await vdbStreamCoarseFirst(pool, await fetch("/smoke.coarse.nvdb"), {
  // After each swap: an explicit densityScale = base x voxelRatio (it is per index voxel), the proxy box
  // from pool.info(id), pool.flush() + grids.update(), and `majorant(event)` re-applied (replace drops it).
  bind: { material, mesh, grids },
  onGrid: (e) => console.log(e.final ? "full" : "preview"),
});

Every bind member is optional. vdbCoarseFirstApply(pool, event, bind) is the same work for an async onGrid. Call pool.update(encoder) / pool.flush() and grids.update() in your frame loop as usual.

Sequences: VDBSequence

VDBSequence plays per-frame .nvdb URLs into ONE pool grid with pool.replace(id, frame): no material rebuild, no shader recompile, and with the capacity reserved, no buffer move either:

import { VDBSequence } from "@pmndrs/vdb/three";

// Reserve room for the largest frame: every replace then writes in place
// (no pool.version change, no VDBGridNode rebind, no new bind group).
const id = pool.add(firstFrame, { capacity: largestFrameBytes });
const material = new VDBVolumeMaterial(renderer, grids, id);
material.densityReferenceAuto = false; // keep the first frame's density scale for every frame

const sequence = new VDBSequence({
  urls: (i) => `/fixtures/embergen/pack/frame_${i}.nvdb`,
  frameCount: 48,
  fps: 24,
  loopMode: "repeat", // or "pingpong", or "once" (hold the last frame); setLoopMode() changes it while playing
});
await sequence.preload();
sequence.start({ pool, id });
// each animation frame:
sequence.update(performance.now()); // may pool.replace(id, frame)
pool.flush();                       // or pool.update(encoder) in your encoder, submitted before three renders
grids.update();
await renderer.renderAsync(scene, camera);

A frame larger than the reserved capacity still plays: the pool moves it and may grow, which is why grids.update() runs after the pool's update every frame. The sequence never blocks the render loop: if a frame isn't decoded when its time comes, it holds the last frame, counts a stall, and keeps going (sequence.stats: frame, decodedAhead, stalls, swaps, replaceMs, failed). A frame whose loader rejects fires onError once and is not retried until seek() or start(); playback skips it. After dispose(), late decodes are dropped and start/seek/resume/preload throw VDB_DISPOSED.

Frame arrays are held by reference: the pool keeps an image until the update that writes it, and until pool.settled() resolves while a growth is unconfirmed. The player never writes into them; a custom loader that recycles frame buffers must not reuse one before await pool.settled() after the update that wrote it.

The froxel volume renderer

VDBFrameVolume and VDBFrameRenderer (ported from mjurczyk/openvdb, re-based on the sparse pool) render volumes through a froxel grid with 'volume' or 'frame' lighting, temporal accumulation, phase functions (including Lorenz-Mie), multiple scattering (two-sided, octaves, neural, multi-scale), spectral media and measured presets, mesh shadows both ways and an emission light. Since 0.2.0 every frame is drawn by the core's froxel renderer (above) on three's device: VDBFrameRenderer is a thin adapter (frameRenderer.core is the VDBFrameRenderer), and its settings are the core's VDBFrameSettings. Volume sources are dense (vdbDenseTextures) or sparse (vdbSparseSource, with LOD). See docs/site/three/frame-renderer.mdx.

Level sets and points

VDBLevelSetMaterial sphere-traces a level-set grid as a lit mesh surface (three's lights, shadows and depth); VDBLevelSetPhysicalMaterial is the same trace on three's physical material (transmissive glass, clearcoat). VDBPoints draws a .vdb point grid (vdbPointRenderData) as instanced sprites, and streams .wvdb points LOD by LOD (VDBPoints.fromWvdbGrid, addWvdbLevel).

.wvdb

@pmndrs/vdb/tools reads and writes mjurczyk/openvdb's .wvdb format (readWvdb, writeWvdb, WvdbStreamReader, bakeWvdb) and converts to and from NanoVDB (vdbToWvdb, nvdbToWvdb, wvdbDenseToNvdb). See docs/site/formats/nvdb-vs-wvdb.mdx.

Device ownership (D8)

The host creates the GPUDevice (with VDBGridPool.requiredLimits(adapter)) and passes it to WebGPURenderer({ device }); the pool and every other pmndrs tool take getDevice(renderer). A renderer built without { device } owns its device and destroys it, with the pool's buffer, in renderer.dispose().

Third-party code

This package is MIT (see LICENSE). The vendored pnanovdb.wgsl and PNanoVDB.h are Apache-2.0. The published package ships vendor/NOTICE and vendor/LICENSE (Apache-2.0) alongside the vendored WGSL, and they must stay in the package and any redistribution. The .wvdb code, the froxel renderer, level sets and points port logic from mjurczyk/openvdb (MIT). Test fixtures are CC0, and fflate is an MIT runtime dependency. The full list, with licences and file locations, is in THIRD_PARTY_NOTICES.md (shipped in the package).

Packaging note (for contributors)

The published export map points only at built dist/ output (dist/{core,tools,three}, one tsc build). Workspace Vite/Vitest/TypeScript configs alias @pmndrs/vdb, @pmndrs/vdb/tools, @pmndrs/vdb/three and @pmndrs/vdb/pnanovdb.wgsl to src/ for source-level development without exposing TypeScript source paths to npm consumers.

Each subpath's index.ts is its public API, frozen by test/api-surface.test.ts (an export-list snapshot and the D32 naming rule). Test oracles and other internals live in src/{core,tools,three}/internal.ts, which re-exports the public API and is imported by path from tests, harnesses and scripts; it is never a package export.