zdbsp-wasm
v0.1.0
Published
ZDBSP node builder for Doom maps compiled to WebAssembly
Maintainers
Readme
zdbsp-wasm
ZDBSP node builder for Doom maps compiled to WebAssembly. Build BSP nodes directly in the browser or Node.js.
Installation
npm install zdbsp-wasmUsage
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);
}API
initZDBSP(): Promise<void>
Initialize the WASM module. Must be called before using other functions.
buildNodes(wadData: Uint8Array, options?: ZDBSPOptions): Promise<ZDBSPResult>
Build BSP nodes for a WAD file.
buildNodesForZDoom(wadData: Uint8Array, mapName?: string): Promise<ZDBSPResult>
Convenience function with ZDoom-optimized settings (GL nodes, extended format).
buildNodesVanilla(wadData: Uint8Array, mapName?: string): Promise<ZDBSPResult>
Convenience function for vanilla Doom compatibility.
Options
| 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") |
Result
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
};
}Demo
Try it online: https://dev.nexusforgia.org/zdbsp-wasm.html
Credits
Based on ZDBSP by Randy Heit and Christoph Oelckers.
License
GPL-2.0 (same as original ZDBSP)
