You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Voxel-based spatial reasoning for multi-agent systems — discrete 3D grid logic.
Overview
voxel-logic provides a complete toolkit for working with 3D voxel grids: coordinate math, sparse storage, shape generation, neighbor queries, flood fill, connected components, set operations, raycasting, and A* pathfinding.
Designed for agents and simulations that need to reason about discrete 3D space efficiently.
Installation
npm install @superinstance/voxel-logic
Quick start
import{voxel,VoxelGrid,filledSphere,floodFill,findPath,raycast,}from'@superinstance/voxel-logic';// Create a sparse gridconstgrid=newVoxelGrid<string>();grid.set(voxel(0,0,0),'spawn');grid.set(voxel(1,0,0),'corridor');// Generate a sphere shapeconstsphere=filledSphere(voxel(5,5,5),3);// Raycast through spaceconsthits=raycast(voxel(0.5,0.5,0.5),voxel(1,0,0),50);// Pathfindingconstpath=findPath(voxel(0,0,0),voxel(10,0,0),(v)=>grid.has(v),// passable check);
API
Coordinates
Function
Description
voxel(x, y, z)
Create a voxel coordinate
voxEq(a, b)
Check equality
voxAdd(a, b) / voxSub(a, b)
Add / subtract offsets
voxScale(v, s)
Scale by a scalar
manhattan(a, b)
Manhattan (L1) distance
chebyshev(a, b)
Chebyshev (L∞) distance
euclidean(a, b)
Euclidean distance
voxKey(v) / fromKey(key)
Encode / decode to string key
Bounds
Function
Description
boundsFrom(a, b)
Create a bounding box from two corners
inBounds(v, bounds)
Check containment
voxelsInBounds(bounds)
Enumerate all voxels in bounds
boundsVolume(bounds)
Count voxels in bounds
Neighbors
Function
Description
faceNeighbors(v)
6 face-adjacent neighbors (von Neumann)
allNeighbors(v)
All 26 neighbors (Moore neighborhood)
boundedFaceNeighbors(v, b)
Face neighbors within bounds
boundedAllNeighbors(v, b)
All neighbors within bounds
VoxelGrid
Sparse hash-map backed storage for arbitrary values at voxel coordinates.