VOLT
Open Source Ecosystem

SpatialAssembler

Native Node.js addon for high-performance GLB assembly from point clouds and meshes.

Overview

@voltstack/spatial-assembler is a C++ native Node.js addon that generates GLB (glTF Binary) 3D models from point clouds, indexed meshes, and typed atomic data. It is the core geometry engine behind VOLT's 3D visualization pipeline.

Package@voltstack/spatial-assembler
LanguageC++17 with Node.js NAPI bindings
PlatformLinux x64
LinksGitHub · npm

Installation

npm install @voltstack/spatial-assembler

API

generateGLB(positions, types)

Generates a GLB buffer from a point cloud with type-based coloring (8 predefined colors).

function generateGLB(
  positions: Float32Array,
  types: Uint32Array
): Buffer
ParameterTypeDescription
positionsFloat32ArrayVertex positions as [x1, y1, z1, x2, y2, z2, ...]
typesUint32ArrayAtom type index per vertex (0–7)

Returns: Buffer — GLB binary data.

generateGLBToFile(positions, types, filePath)

Same as generateGLB, but writes the result directly to disk.

function generateGLBToFile(
  positions: Float32Array,
  types: Uint32Array,
  filePath: string
): boolean

Returns: booleantrue on success.

generatePointCloudGLB(positions, colors)

Generates a GLB from a point cloud with explicit RGBA colors.

function generatePointCloudGLB(
  positions: Float32Array,
  colors: Float32Array
): Buffer
ParameterTypeDescription
positionsFloat32ArrayVertex positions as [x, y, z, ...]
colorsFloat32ArrayRGBA colors per vertex as [r, g, b, a, ...]

Returns: Buffer — GLB binary data.

generateMeshGLB(positions, normals, indices, hasColors, colors, bounds, material)

Generates a GLB from an indexed triangle mesh with normals and PBR material properties.

function generateMeshGLB(
  positions: Float32Array,
  normals: Float32Array,
  indices: Uint32Array | Uint16Array,
  hasColors: boolean,
  colors: Float32Array,
  bounds: Bounds,
  material: Material
): Buffer
ParameterTypeDescription
positionsFloat32ArrayVertex positions
normalsFloat32ArrayVertex normals
indicesUint32Array | Uint16ArrayTriangle indices
hasColorsbooleanWhether to include vertex colors
colorsFloat32ArrayRGBA colors (used if hasColors is true)
boundsBoundsBounding box { minX, minY, minZ, maxX, maxY, maxZ }
materialMaterialPBR material properties
interface Bounds {
  minX: number; minY: number; minZ: number;
  maxX: number; maxY: number; maxZ: number;
}

interface Material {
  baseColor: [number, number, number, number];
  metallic: number;
  roughness: number;
  emissive: [number, number, number];
  doubleSided: boolean;
}

Returns: Buffer — GLB binary data.

applyPropertyColors(colorIndices, colorValues)

Maps scalar property values to a gradient color palette (Viridis, Plasma, Blue-Red, or Grayscale with a 1024-entry LUT).

function applyPropertyColors(
  colorIndices: Uint32Array,
  colorValues: Float32Array
): Float32Array
ParameterTypeDescription
colorIndicesUint32ArrayIndex into the color map per vertex
colorValuesFloat32ArrayRGB values for gradient interpolation

Returns: Float32Array — RGBA colors per vertex.

taubinSmooth(positions, indices, lambda, mu, iterations)

Applies Taubin smoothing (bilateral mesh filtering) to a triangle mesh. Modifies positions in place.

function taubinSmooth(
  positions: Float32Array,
  indices: Uint32Array | Uint16Array,
  lambda: number,
  mu: number,
  iterations: number
): boolean
ParameterTypeDescription
positionsFloat32ArrayMesh vertex positions (modified in place)
indicesUint32Array | Uint16ArrayTriangle indices
lambdanumberPositive smoothing factor
munumberNegative smoothing factor (shrinkage compensation)
iterationsnumberNumber of smoothing passes

Returns: booleantrue on success.

Performance

SpatialAssembler is optimized for large atomic datasets:

  • AVX2/BMI2 SIMD — Runtime CPU feature detection with vectorized operations.
  • Lock-free parallel radix sort — Per-thread histograms eliminate atomic operations.
  • Morton encoding — Z-order curve for spatial coherence.
  • 32-byte aligned memory — Cache-friendly data layout.
  • Multi-threaded — Automatic hardware concurrency detection.
  • Compiled with -O3 -ffast-math -pthread.

On this page