ZDBSP node builder for Doom maps compiled to WebAssembly
npm install zdbsp-wasmZDBSP node builder for Doom maps compiled to WebAssembly. Build BSP nodes directly in the browser or Node.js.
``bash`
npm install zdbsp-wasm
`typescript
import { initZDBSP, buildNodes } from 'zdbsp-wasm';
// Initialize the WASM module (call once)
await initZDBSP();
// Read your WAD file
const wadData = new Uint8Array(await file.arrayBuffer());
// Build nodes with options
const result = await buildNodes(wadData, {
buildGLNodes: true,
extended: true,
compress: false,
mapName: 'MAP01', // optional: process specific map only
});
if (result.success) {
console.log(Built ${result.stats.nodes} nodes in ${result.stats.timeMs}ms);`
// result.data contains the processed WAD
} else {
console.error(result.error);
}
Initialize the WASM module. Must be called before using other functions.
Build BSP nodes for a WAD file.
Convenience function with ZDoom-optimized settings (GL nodes, extended format).
Convenience function for vanilla Doom compatibility.
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| buildGLNodes | boolean | false | Build GL nodes for hardware rendering |conformNodes
| | boolean | false | Build GL nodes that match normal nodes |glOnly
| | boolean | false | Only build GL nodes, skip regular nodes |extended
| | boolean | false | Use extended node format for large maps |compress
| | boolean | false | Compress nodes with zlib |compressNormalOnly
| | boolean | false | Compress only normal nodes |glV5
| | boolean | false | Use GL nodes v5 format |emptyBlockmap
| | boolean | false | Create empty blockmap |rejectMode
| | string | 'dont_touch' | 'dont_touch', 'create_zeroes', or 'empty' |maxSegs
| | number | 64 | Maximum segs per node |splitCost
| | number | 8 | Cost for splitting segs |diagonalCost
| | number | 16 | Cost for diagonal splitters |checkPolyobjs
| | boolean | true | Check for polyobject subsector splits |noPrune
| | boolean | false | Keep unused sidedefs and sectors |mapName
| | string | undefined | Process only specified map (e.g., "MAP01") |
`typescript``
interface ZDBSPResult {
success: boolean;
data?: Uint8Array; // Output WAD data
error?: string; // Error message if failed
stats?: {
nodes: number; // Number of nodes created
segs: number; // Number of segs created
subsectors: number; // Number of subsectors created
timeMs: number; // Processing time in milliseconds
};
}
Try it online: https://dev.nexusforgia.org/zdbsp-wasm.html
Based on ZDBSP by Randy Heit and Christoph Oelckers.
GPL-2.0 (same as original ZDBSP)