@tty-pt/areole
Universal Node.js and Browser bindings forlibareole, the distance-adaptive multi-scale spatial quadtree, 6-plane Gribb-Hartmann frustum culling, and LOD hierarchy engine. Canonical C headers:<ttypt/areole.h>and<ttypt/areole_glsl.h>.
๐ Full C & Architectural Documentation: See the main libareole GitHub README for single-arena memory layouts (ar_config_t), 3D manifold AABB callbacks, and GLSL ES 3.0 vertex parity.
1. Overview & Domain Concepts
libareole (@tty-pt/areole) is a domain-agnostic spatial hierarchy and level-of-detail (LOD) culling engine for real-time 3D, 2.5D, and 2D procedural worlds:
- Single-Arena Zero-Allocation Traversal & O(1) LRU Pool:
- Allocates the entire quadtree node pool, bounded
ar_sample_tsub-pool, vertex buffers, and spatial hash table in a single contiguous arena at startup (createAreoleSystem), performing zero heap allocations during per-frame camera motion with per-framear_metrics_ttelemetry.
- Exact SAT 6-Plane Frustum, 3D Manifold Horizon & 2D Software Hi-Z Occlusion Culling:
- Extracts exact frustum planes from the active camera view (supporting full $360^\circ$ yaw, $0^\circ\text{โ}85^\circ$ pitch, cached Z bounds tightening, planetary horizon curvature sag, pluggable 3D manifold AABB / normal-cone horizon callbacks
ar_bounds_3d_fn/ar_cull_3d_fn, and a 96ร54 conservative 2D software Hi-Z occluderar_occluder_twith deduplicated mid-split pre-rasterization).
- Coarse-First Max-Heap LOD Selection, Continuous Vertex Morphing & Async Population ($O(1)$ Active Budget):
- Guarantees complete 4-quadrant horizon coverage within a bounded
maxActivechunk budget with breadth-first budget coarsening, per-chunk continuous LOD morph factor (ar_draw_item_t.morphin[0.0, 1.0]), vectorized scanline (ar_row_sampler_fn) and 4-wide batched (ar_eval_row4_fn) row callbacks, watertight cross-LOD seam welding, and background worker population (<ttypt/wq.h>or externalar_async_ops_tWASM Web Worker pools).
- Hierarchical Point, Attribute & Height-Only Probing (
.probe(wx, wy)/ar_probe_val):
- Evaluates continuous interpolated scalar displacement (
value), packed 32-bitrgba,flags, and 8-byte material/biome payload (attr[0..7]) at any world coordinate, plus fast height-only scalar probes (ar_probe_val/ar_probe_view_val) in C/WASM.
2. Installation
npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/areole
Native OS & Mobile Packages (tty.pt): Prebuilt native C packages (libareole) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, Scoop, MSYS2), OpenBSD (pkg_add), plus static mobile sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ โ libareole.xcframework + SwiftPM) are available via the tty.pt package repositories.
3. Quickstart
import { createAreoleSystem } from "@tty-pt/areole";
// 1. Allocate a spatial quadtree hierarchy (baseW = 160, baseH = 128)
const sys = createAreoleSystem(160, 128);
// 2. Query visible LOD chunks for the current 3D camera frustum
const nodes = sys.update({
camX: 0,
camY: 0,
camZ: 120,
pitch: 0.6,
yaw: 0.0,
fov: 1.0,
zoom: 1.0,
viewportW: 1920,
viewportH: 1080,
effCamDist: 400
}, 1 /* worldId */);
console.log("Visible LOD chunks:", nodes.length, nodes[0]);
// 3. Probe exact interpolated surface attributes at world coordinate (wx, wy)
const sample = sys.probe(32, 48, 1);
console.log("Probed sample:", sample);
// 4. Release arena allocation when finished
sys.destroy();
4. JavaScript / TypeScript API Reference
createAreoleSystem(baseW?, baseH?, gridDim?, poolCap?, maxActive?, maxLevels?): AreoleSystem
Creates an ar_system_t spatial hierarchy instance and returns an AreoleSystem controller:
baseW,baseH: Base level-0 chunk dimensions in world units (defaults:160,128).gridDim: Quads per chunk edge (default:32).poolCap: Total cached chunk slots in the arena (default:128).maxActive: Maximum active chunks returned per frame query (default:64).maxLevels: Maximum quadtree subdivision depth (default:16).
AreoleSystem Methods
.update(view: AreoleView, world?: number): AreoleNodeSummary[]: Runs 6-plane frustum culling and LOD selection, returning{ ox, oy, w, h, level, flags, minValue, maxValue }for each active chunk..probe(wx: number, wy: number, world?: number): AreoleSample | null: Probes interpolated{ value, rgba, flags, attr }at world coordinates(wx, wy)..clear(): void: Evicts cached quadtree nodes without freeing the arena..destroy(): void: Frees the underlyingar_system_tarena.
getAreoleWasm(): WebAssembly.Instance
Returns the initialized areole.wasm reactor instance on @tty-pt/stele's shared linear memory substrate.
5. C Development Headers & Native Integration
CFLAGS += -I./node_modules/@tty-pt/areole/include
LDLIBS += -lareole -lm
License
BSD-2-Clause โ Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.