VOLT
Open Source Ecosystem

SpatialAssembler

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

Overview

Generates GLB (glTF Binary) 3D models from point clouds, indexed meshes, and typed atomic data — the 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, min, max)

Generates a GLB buffer from a point cloud with type-based coloring (8 predefined colors). Atoms are Morton-sorted within the supplied bounding box for spatial coherence.

function generateGLB(
  positions: Float32Array,
  types: Uint16Array,
  min: number[],
  max: number[]
): Buffer
ParameterTypeDescription
positionsFloat32ArrayVertex positions as [x1, y1, z1, x2, y2, z2, ...]
typesUint16ArrayAtom type index per vertex (clamped to 0–7 for color selection)
minnumber[]Bounding box minimum as [x, y, z]
maxnumber[]Bounding box maximum as [x, y, z]

Returns: Buffer — GLB binary data.

generateGLBToFile(positions, types, min, max, filePath)

Same as generateGLB, but streams the result directly to disk (bypasses the Node.js buffer size limit, suitable for very large datasets).

function generateGLBToFile(
  positions: Float32Array,
  types: Uint16Array,
  min: number[],
  max: number[],
  filePath: string
): boolean

Parameters match generateGLB, plus filePath (string) — output file path.

Returns: booleantrue on success.

generatePointCloudGLB(positions, colors, min, max)

Generates a GLB from a point cloud with explicit, pre-computed vertex colors.

function generatePointCloudGLB(
  positions: Float32Array,
  colors: Float32Array,
  min: number[],
  max: number[]
): Buffer
ParameterTypeDescription
positionsFloat32ArrayVertex positions as [x, y, z, ...]
colorsFloat32ArrayPer-vertex colors, either RGB ([r, g, b, ...]) or RGBA ([r, g, b, a, ...]). The layout is auto-detected from the array length.
minnumber[]Bounding box minimum as [x, y, z]
maxnumber[]Bounding box maximum as [x, y, z]

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 (only read when hasColors is true; may be omitted/undefined otherwise)
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;
}

doubleSided defaults to true when omitted.

Returns: Buffer — GLB binary data.

applyPropertyColors(values, minVal, maxVal, gradientType)

Maps scalar property values onto a gradient color palette using a 1024-entry lookup table. Each value is normalized into the [minVal, maxVal] range, clamped, and sampled from the selected gradient.

function applyPropertyColors(
  values: Float32Array,
  minVal: number,
  maxVal: number,
  gradientType: number
): Float32Array
ParameterTypeDescription
valuesFloat32ArrayOne scalar value per vertex
minValnumberLower bound of the value range (maps to the start of the gradient)
maxValnumberUpper bound of the value range (maps to the end of the gradient)
gradientTypenumberGradient selector: 0 = Viridis, 1 = Plasma, 2 = Blue-Red, 3 = Grayscale (out-of-range values fall back to 0)

Returns: Float32Array — RGB colors per vertex as [r, g, b, ...] (3 components per vertex).

taubinSmooth(positions, indices, iterations)

Applies Taubin smoothing (bilateral mesh filtering) to a triangle mesh. Modifies positions in place. The lambda/mu smoothing factors are fixed internally (0.5 and -0.52).

function taubinSmooth(
  positions: Float32Array,
  indices: Uint32Array | Uint16Array,
  iterations: number
): boolean
ParameterTypeDescription
positionsFloat32ArrayMesh vertex positions (modified in place)
indicesUint32Array | Uint16ArrayTriangle indices
iterationsnumberNumber of smoothing passes (<= 0 is a no-op)

Returns: booleantrue on success.

Performance

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