vdb-js
JavaScript implementation of OpenVDB.
The idea is to keep the code as close as possible to the original source.
Usage
JavaScript
Set/get voxel (with cached access)
let vdb = ; let grid = -1;let accessor = grid; accessor;accessor; // 42
Iterate over active voxels
accessor;accessor;accessor; let counter = 0;for const voxel of grid counter++; console; // 42 console; // 3
Ray intersection
let eye = 0 -1 0;let direction = 0 1 0;let ray = eye direction; let intersector = grid; if intersector console; let start = 0 -10 0;let end = 0 10 0;let timeSpanRef = start end; intersector; console;console;
TypeScript
; ;; accessor.setValueOn, 42;accessor.getValue; // 42
Limitations
Currently, only the following hard-coded tree structure/hierarchy is supported:
InternalNode2.DIM
= 256InternalNode1.DIM
= 64LeafNode.DIM
= 8
─ ─┌┬┬┬──────────┬┬┬┐─ ─
|||| RootNode ||||
─ ─└┴┴┴─────┬────┴┴┴┘─ ─
┌─────────┴─────────┐
▼ ▼
┌───────────────┐ ┌───────────────┐ ┌─ ─ ─
| InternalNode2 | | InternalNode2 | |
└───────┬───────┘ └───────┬───────┘ └─ ─ ─
┌─────────┴─────────┐ └─────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌─ ─ ─
| InternalNode1 | | InternalNode1 | | InternalNode1 | |
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘ └─ ─ ─
┌─────────┴────┐ ┌┴─────────────┐ └────────┐
▼ ▼ ▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─ ─ ─
| LeafNode | | LeafNode | | LeafNode | | LeafNode | | LeafNode | |
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └─ ─ ─
OpenVDB
- Origianl repo
- High-level summary of the terminology and basic components
- Cookbook with code examples
- Original paper from Ken Museth: VDB: High-Resolution Sparse Volumes with Dynamic Topology
- Ken Museth explaining VDB: OpenVDB: An Open Source Data Structure and Toolkit for High-Resolution Volumes
- VDB on GPU: Fast Fluid Simulations with Sparse Volumes on the GPU
- Raytracing Sparse Volumes with NVIDIA® GVDB in DesignWorks
Publish
npm login
yarn nx build vdb
cd ./dist/libs/vdb
npm publish