<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Get all available spawn types. Returns: Array of spawn type names Get spawn types by category. Parameters: (string) — Category name Returns: Array of spawn type names Get the default color for a spawn type. Parameters: (string) — Spawn type (cube, sphere, cylinder, etc.) Returns: RGB color array Get the mesh type for a spawn type. Parameters: (string) — Spawn type Returns: Mesh type key Resolve color and mesh for a spawned entity. Uses spawnerProps.color if provided, otherwise falls back to type defaults. Parameters: (string) — Spawn type (Object) — Optional spawner properties with color override (Object) — Object mapping mesh keys to mesh instances Returns: { color: number[], mesh: Object, meshKey: string } Create a mesh lookup object from individual mesh references. Parameters: (Object) — Mesh references Returns: Mesh lookup object Constants — Default colors for each spawn type — Mesh type mapping (which mesh to use for each spawn type) — Spawn type categories for UI organization <! HUMAN NOTES Notes & Examples No hand authored notes yet. Add page notes in or a reusable block in — see API Reference Standard.


version.js

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ============================================================ Particle Realms — Canonical Version Source ============================================================ Import this module from anywhere in the engine or editor. The landing page (tests/index.html) also reads these values. ============================================================ Constants <! HUMAN NOTES Notes & Examples No hand authored notes yet. Add page notes in or a reusable block in — see API Reference Standard.


voxel/ChunkCullCompute.js

voxel/ChunkCullCompute.js
Classes
class ChunkCullCompute
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Initialize the GPU culling system Set Hi Z texture from HiZPass Upload chunk data for culling Run GPU culling Extract frustum planes from view projection matrix (CPU) Read back culling stats (async, for debugging) Destroy GPU resources <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/ChunkRegistry.js

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ChunkRegistry.js Central Chunk Existence and Integrity Registry Solves: 1. Duplicate generation fast O(1) existence check before generating 2. Corruption detection content hash verification 3. Race conditions atomic claim/release for chunk operations 4. Missing chunks tracks all known chunks with metadata Uses: In memory Map for fast lookups Content hashing (xxHash) for integrity verification Temp file staging for atomic saves Persistent index file for cross session awareness Classes Bloom Filter for ultra fast chunk existence checks O(1) time for add/check No false negatives (if says "no", definitely doesn't exist) Small false positive rate ( 0.8%) Uses 2% memory of equivalent Set Method Signature Summary Generate k hash indices from chunk coordinates Uses double hashing: h(i) = h1 + i h2 Add chunk to bloom filter Check if chunk might exist (no false negatives) Clear the bloom filter Get estimated false positive rate Method Signature Summary Initialize registry, optionally loading existing index Check if chunk exists (in memory or on disk) O(1) lookup use this before generating! Uses bloom filter for fast negative check first Check if chunk exists on disk specifically Check if chunk is currently being processed Get existing pending promise for deduplication Claim a chunk for generation (prevents duplicates) Claim a chunk for loading Release claim after operation completes Register a chunk after successful load or generation Mark chunk as saved to disk Mark chunk as corrupted Verify chunk integrity by comparing hash Update hash after chunk modification Register multiple chunks as existing on disk (fast bulk init) Get all chunks needing save Get chunks in a region Load index from


voxel/ChunkRegistry.js

hash after chunk modification Register multiple chunks as existing on disk (fast bulk init) Get all chunks needing save Get chunks in a region Load index from disk Save index to disk Get entry for a chunk Get stats including bloom filter performance Debug: dump registry state Functions Fast 32 bit hash for chunk content verification Parameters: (Uint8Array Uint32Array) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: 32 bit hash Hash voxel data for quick integrity check Uses sampling for very large arrays (faster) Parameters: (Uint8Array) — No description in source JSDoc. Encode 3D chunk coordinates to Morton code (Z order) Interleaves bits for better cache locality in spatial queries Parameters: (number) — Chunk X ( 1024 to 1023) (number) — Chunk Y ( 1024 to 1023) (number) — Chunk Z ( 1024 to 1023) Returns: 32 bit Morton code Decode Morton code back to 3D coordinates Append trailer canary to data for torn write detection Verify trailer canary is present (write was complete) Get the global ChunkRegistry instance Initialize the global registry with a storage backend Parameters: (Object) — No description in source JSDoc. Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/ChunkSorter.js

voxel/ChunkSorter.js
Classes
class ChunkSorter
Functions
getCameraForward(viewMatrix)
getCameraPosition(invViewMatrix)
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes ChunkSorter Manages chunk draw order and visibility Method Signature Summary Update camera state Calculate which face directions are visible from camera A face is visible if it points toward the camera (dot product with forward 0) Check if a specific face direction is visible Sort chunks front to back by distance from camera Uses cascaded bucket sort for O(n) performance instead of O(n log n) Get sorted chunks iterator Get visible face count (for statistics) Get visible face names Get statistics Functions Utility function to extract camera forward from view matrix Parameters: (Float32Array) — 4x4 view matrix Returns: Forward direction [x, y, z] Utility function to extract camera position from inverse view matrix Parameters: (Float32Array) — Inverse 4x4 view matrix Returns: Position [x, y, z] Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/ColoredLighting.js

voxel/ColoredLighting.js
Classes
class ColoredLightingSystem
Functions
packLight(r, g, b, sky = 0)
unpackLight(packed)
getChannel(packed, shift)
lightMax(a, b)
lightDecrement(packed, amount = 1)
hasLight(packed)
lightToRGB(packed, skyBrightness = 1.0)
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Get or create light data for a chunk Get light level at world position Set light level at world position Get material opacity Get material light emission Add a light source at position Remove light source at position Initialize lighting for a chunk based on light emitting materials Initialize sky light propagating down from top of chunk Process light propagation queue Call this in the update loop Propagate light from a source position Propagate light removal Handle block placement (may need to remove light) Handle block removal (light can now propagate through) Set sky brightness (0 15, for day/night cycle) Get light at position as normalized float RGB Clear all light data (for chunk unloading) Load configuration from engine.cfg section Functions Pack RGB + Sky into a 16 bit value Unpack light into components Get single channel from packed light Component wise maximum of two light values Component wise decrement with saturation (no underflow) Check if light value is non zero Convert light to normalized RGB (0 1 range) <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/DirtyChunkManager.js

class GeometryDirtyTracker extends DirtyChunkManager

class LightingDirtyTracker extends DirtyChunkManager

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Represents a dirty chunk entry Method Signature Summary Get unique key for this chunk Add additional flags Check if specific flag is set Serialize for GPU upload (16 bytes aligned) Method Signature Summary Update camera position for priority calculation Default priority function (damage first, then distance to camera) Mark a chunk as dirty Mark all 26 neighbors with BOUNDARY flag Mark chunk clean (processing complete) Check if chunk is dirty Get dirty flags for a chunk Begin new frame swap queues and prepare for processing Get chunks to process this frame, sorted by priority Get GPU ready buffer data for dirty chunks End frame clean up processed chunks Clear all dirty state Get statistics Debug string Geometry specific dirty tracker (for mesh rebuilds) Method Signature Summary Mark chunk as DAMAGE priority (processes first, bypasses budget) Get damage chunks first (no limit always process all damage) Count pending damage chunks Lighting specific dirty tracker (for DDGI updates) Method Signature Summary Functions Parse chunk key to coordinates Parameters: (string) — No description in source JSDoc. Create chunk key from coordinates Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Constants — Maximum chunks that can be processed per frame — Chunk states Re exports <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position.


voxel/DirtyChunkManager.js

provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/FaceListMesher.js

voxel/FaceListMesher.js
Classes
class GPUBufferPool
class FaceListMesher
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Method Signature Summary Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/FacePool.js

voxel/FacePool.js
Classes
class FacePool
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/MC33Tables.js

voxel/MC33Tables.js
Functions
asymptoticDecider(v0, v1, v2, v3)
isFaceAmbiguous(cubeIndex, faceIndex)
getAmbiguousFaces(cubeIndex)
interiorTest(values)
getMC33Subcase(cubeIndex, values)
generateWGSLTables()
rotateEdges(edges, rotation)
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Evaluate the asymptotic decider for a face Given 4 corner values of a face (v0, v1, v2, v3 in order around face), determine how the isosurface crosses the face. For a face to be ambiguous, corners must alternate in sign: (v0 0, v1 < 0, v2 0, v3 < 0) or vice versa The asymptotic decider computes: A = v0 + v2 (diagonal sum) B = v1 + v3 (other diagonal sum) If A (v0 v1) 0: connect (v0,v2) pair Else: connect (v1,v3) pair Equivalently, compute Q = v0 v2 v1 v3 Q 0: separating, Q < 0: connecting Parameters: (number) — Corner 0 value (number) — Corner 1 value (number) — Corner 2 value (number) — Corner 3 value Returns: 1 if ambiguous (connecting), +1 if separating, 0 if not ambiguous Check if a face has ambiguity given cube configuration Parameters: (number) — 8 bit cube configuration (number) — Face index (0 5) Get all ambiguous faces for a cube configuration Parameters: (number) — 8 bit cube configuration Returns: Array of ambiguous face indices Test for interior ambiguity in Case 13 configurations Case 13 has a potential tunnel through the cube center The interior test computes the bilinear patch at cube center and checks if it separates or connects the corner groups Parameters: (number[]) — 8 corner values Returns: 1, 0, or +1 indicating interior topology Compute the MC33 subcase for a given cube configuration Parameters: (number) — 8 bit cube configuration (number[]) — 8 corner density values Returns: } Generate WGSL constant arrays for MC33 tables For use in compute shaders Apply rotation to edge indices Parameters: (number[]) — Triangle edge list (number) — Rotation index


voxel/MC33Tables.js

constant arrays for MC33 tables For use in compute shaders Apply rotation to edge indices Parameters: (number[]) — Triangle edge list (number) — Rotation index (0 47) Returns: Rotated edge list Constants — MC33 base case for each of the 256 cube configurations Standard MC has 15 cases, MC33 extends to 33 by splitting ambiguous ones Cases 0 14: Standard unambiguous cases Cases with face ambiguity: 3, 4, 6, 7, 10, 12, 13 Cases with interior ambiguity: 4, 6, 7, 10, 12, 13 — Number of subcases for each MC33 case Most cases have 1 subcase (no ambiguity) Ambiguous cases have 2 6 subcases depending on face/interior tests — Face indices for the 6 cube faces Each face defined by 4 corner indices in CCW order (from outside) — For each ambiguous case, which faces need to be tested Bit flags: bit 0 = face 0, bit 1 = face 1, etc. — Subcase lookup for each ambiguous case Index by face test results (bit flags) — Triangle configurations for MC33 subcases For ambiguous cases, provides alternate triangulations Format: [case][subcase] = [edge indices for triangles, 1 terminated] Note: This is a subset of the full 1296 entry table Full table would be generated programmatically or loaded from binary — Rotation lookup to map arbitrary configs to canonical form MC33 uses 48 symmetries (24 rotations × 2 reflections) This reduces the 256 configurations to 23 canonical cases Each entry: [canonical index, rotation index] <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/MarchingCubesMesher.js

meshChunkSmooth(chunk, getDensity, options = {})

meshChunkMC33(chunk, getDensity, options = {})

generateTransitionCell(densityHigh, densityLow, face, cellSize, isolevel = 0)

dualContourVertex(density, gradients, isolevel = 0)

calculateWorldSpaceAO(sampleDensity, wx, wy, wz, radius = 2, samples = 8)

calculateGradientAO(sampleDensity, wx, wy, wz)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: MarchingCubesMesher.js Smooth Voxel Terrain via Isosurface Extraction INTEGRATION: GPU compute shader for parallel cube processing Uses VoxelMeshCompute for output buffer management Integrates with ChunkManager for chunk based meshing Implements the Marching Cubes algorithm for smooth terrain: Extracts isosurface from 3D density field Produces smooth, organic terrain instead of blocky voxels Supports interpolated vertex positions for smooth gradients Generates per vertex normals for proper lighting fBM SDF terrain (Inigo Quilez style) for native smooth noise MC33 Extension (Chernyaev 1995): Resolves topological ambiguities for watertight meshes Uses asymptotic decider for face ambiguity resolution Interior tests for tunnel cases (Case 13) 33 distinct cases vs standard 15 Based on: Lorensen & Cline's Marching Cubes (1987) Chernyaev's Marching Cubes 33 (1995) Inigo Quilez fBM SDF: https://iquilezles.org/articles/fbmsdf/ Usage: const mesh = meshChunkSmooth(chunk, getDensity); const meshMC33 = meshChunkMC33(chunk, getDensity); // Watertight // Or with SDF: const density = sdfTerrain(x, y, z, config); Classes Marching Cubes Mesher class for integration with existing systems Method Signature Summary Initialize GPU resources for compute based meshing Mesh a chunk using the stored density function (CPU fallback) Upload density field to GPU Get GPU vertex buffer for rendering Load config from object Functions Mesh a chunk using Marching Cubes for smooth terrain Parameters: (Object) — Voxel chunk with density data (Function) — Function(x,y,z) returning density value (Object) — Meshing options Returns: Mesh data with vertices, normals, indices Mesh a chunk using MC33 for watertight meshes


voxel/MarchingCubesMesher.js

returning density value (Object) — Meshing options Returns: Mesh data with vertices, normals, indices Mesh a chunk using MC33 for watertight meshes Resolves topological ambiguities that cause holes in standard MC Parameters: (Object) — Voxel chunk with density data (Function) — Function(x,y,z) returning density value (Object) — Meshing options Returns: Mesh data with vertices, normals, indices Test if a face is ambiguous and resolve using asymptotic decider Exported for use in GPU shader validation Parameters: (number) — Cube configuration (0 255) (number[]) — 8 corner density values (number) — Face to test (0 5) Returns: } Smooth minimum (polynomial) blends two distances smoothly Parameters: (number) — First distance (number) — Second distance (number) — Blend factor (0.1 = sharp, 1.0 = very smooth) fBM (Fractal Brownian Motion) noise Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. (Object) — {octaves, persistence, lacunarity} SDF Terrain density function (Inigo Quilez style) Returns negative inside terrain, positive outside Parameters: (number) — World X (number) — World Y (height) (number) — World Z (Object) — Terrain configuration SDF Sphere primitive SDF Box primitive Union of two SDFs Smooth union of two SDFs Subtraction of SDFs (d2 from d1) Intersection of SDFs Generate transition cell mesh for LOD boundary Parameters: (Float32Array) — High res density (full resolution) (Float32Array) — Low res density (half resolution) (number) — Boundary face (0=+X, 1= X, 2=+Y, 3= Y, 4=+Z, 5= Z) (number) — Cell size at high resolution (number) — Isosurface threshold Returns: {vertices: Float32Array, indices: Uint32Array} Check if chunk needs transition cells on a face Parameters:


voxel/MarchingCubesMesher.js

resolution (number) — Isosurface threshold Returns: {vertices: Float32Array, indices: Uint32Array} Check if chunk needs transition cells on a face Parameters: (number) — This chunk's LOD level (number) — Neighbor chunk's LOD level Returns: True if transition cells needed Get transition cell size ratio Parameters: (number) — This chunk's LOD (number) — Neighbor's LOD Returns: Size ratio (1, 2, 4, etc.) Dual Contouring vertex placement using QEF (Quadric Error Function) Unlike Marching Cubes, places vertex at optimal position inside cell Parameters: (Float32Array) — 8 corner densities (Array) — 8 gradient vectors at corners (number) — Surface threshold Returns: } Optimal vertex position Check if cell contai


voxel/MaterialSchema.js

voxel/MaterialSchema.js
Functions
getMaterialId(name)
getMaterialName(id)
getMaterialColor(id)
getMaterialProperties(id)
isTransparent(id)
isSolid(id)
isFluid(id)
isEmissive(id)
validateSchema()
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Get material ID by name (safe lookup) Parameters: (string) — Material name (e.g., 'STONE', 'LEAVES') Returns: Material ID, or 0 (AIR) if not found Get material name by ID (safe lookup) Parameters: (number) — Material ID Returns: Material name, or 'UNKNOWN' if not found Get material color by ID Parameters: (number) — Material ID Returns: RGBA color array [0 255] Get material properties by ID Parameters: (number) — Material ID Returns: Properties object Check if material is transparent Parameters: (number) — Material ID Check if material is solid Parameters: (number) — Material ID Check if material is fluid Parameters: (number) — Material ID Check if material is emissive Parameters: (number) — Material ID Validate schema integrity Returns: { valid: boolean, errors: string[] } Constants — Material definition schema Each material has: name: Unique identifier (used as enum key) color: RGBA array [0 255, 0 255, 0 255, 0 255] colorNormalized: RGBA array [0 1, 0 1, 0 1, 0 1] (auto generated) properties: Material behavior flags <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/MeshletCullCompute.js

voxel/MeshletCullCompute.js
Classes
class MeshletCullCompute
Notes & Examples
Voxel World System


voxel/NeighborCache.js

voxel/NeighborCache.js
Classes
class ChunkNeighborCache
class NeighborCacheManager
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes ChunkNeighborCache Per chunk neighbor references Method Signature Summary Set a neighbor reference Get a neighbor chunk Clear all neighbor references Get voxel at local position, crossing chunk boundaries if needed Check if voxel is solid at position (crosses boundaries) Get whether all neighbors are loaded Get count of loaded neighbors NeighborCacheManager Manages neighbor caches for all chunks Method Signature Summary Initialize with chunk manager reference Get or create cache for a chunk Called when a chunk is loaded update neighbor links Called when a chunk is unloaded remove neighbor links Get voxel at world position using cached neighbors Rebuild all neighbor links (call after bulk loading) Get chunks that need remeshing due to neighbor changes Get stats Clear all caches Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/ProceduralMaterialBaker.js

voxel/ProceduralMaterialBaker.js
Classes
class ProceduralMaterialBaker
Notes & Examples
Voxel World System


voxel/SubChunkMeshCompute.js

voxel/SubChunkMeshCompute.js
Classes
class SubChunkMeshCompute
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Set metrics callback for performance tracking Set external buffer pool Initialize GPU resources Get or create a vertex buffer from pool Get or create an index buffer from pool Get or create an indirect buffer from pool Return buffers to pool Mesh a 4³ sub chunk on GPU Mesh an 8³ sub chunk on GPU Get performance statistics <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/TextureArrayManager.js

textureArrayMaterialNoiseDelta(px, py, materialIndex, amplitude = 0.1)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: TextureArrayManager.js Texture Array for Voxel Materials Uses a 2D texture array instead of a texture atlas for voxel materials. Benefits over atlas: No UV calculation needed (just use material index) Proper mipmapping per texture (no bleeding) Cleaner shader code Easy to add/remove materials Usage in shader: @group(0) @binding(X) var materials: texture 2d array<f32 ; let color = textureSample(materials, sampler, uv, materialIndex); Classes TextureArrayManager Manages a texture array for voxel materials Method Signature Summary Initialize the texture array Generate solid color textures for all materials Generate mipmaps for all layers Load a texture for a specific material Set material color (regenerates texture) Get texture array view for binding Get sampler for binding Create bind group entries for this texture array Load configuration from engine.cfg section Destroy the texture array Functions Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelAO.js

calculateVertexAO(isOpaque, x, y, z, face, corner)

calculateFaceAO(isOpaque, x, y, z, face)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes VoxelAOCalculator GPU compute shader for AO calculation Method Signature Summary Initialize the AO calculator Create precomputed AO lookup table Key: 8 bit neighbor mask Value: AO value (0 255) Fast AO lookup using precomputed table Calculate AO for an entire chunk during meshing Load configuration from engine.cfg section Destroy resources Functions Calculate vertex AO for a single corner Parameters: (Function) — (x, y, z) = boolean (number) — Voxel X (number) — Voxel Y (number) — Voxel Z (number) — Face direction (0 5) (number) — Corner index (0 3) Returns: AO value 0.0 (fully occluded) to 1.0 (no occlusion) Calculate all 4 corner AO values for a face Parameters: (Function) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: [ao0, ao1, ao2, ao3] Pack 4 AO values into a single u32 (8 bits each) Parameters: (Array<number ) — 4 AO values (0.0 1.0) Returns: Packed u32 Unpack u32 to 4 AO values Parameters: (number) — No description in source JSDoc. Determine if face vertices should be flipped for better AO interpolation Fixes the "anisotropy" problem where diagonal looks different based on quad orientation Parameters: (Array<number ) — 4 AO values Returns: True if vertices should be flipped Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera


voxel/VoxelAO.js

system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelConstants.js

voxel/VoxelConstants.js
Functions
getDepthTier(y)
getDepthTierBlend(y)
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Get the depth tier configuration for a given Y coordinate Parameters: (number) — World Y coordinate Returns: Depth tier config Interpolate between depth tiers for smooth transitions Parameters: (number) — World Y coordinate Returns: } Constants — Depth tiers define how terrain generation changes with depth. Each tier has different noise parameters, materials, and features. <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelMeshCompute.js

voxel/VoxelMeshCompute.js
Classes
class VoxelMeshCompute
Constants
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Set metrics callback for performance tracking Reset per frame stats (call at start of each frame) Initialize the compute system Enable turbo mode for initial load (uses fast path for ALL chunks) Queue a chunk for meshing (async, batched) DAMAGE chunks and TURBO MODE use FAST PATH no readback, 3x faster FAST PATH: Mesh chunk without readback uses pre allocated max buffers 3x faster than regular path by eliminating GPU CPU sync Get an available buffer set for parallel meshing Skips the damage reserved buffer set TURBO MODE: Fire and forget parallel mesh processing Continuously launches meshes without waiting maximum GPU saturation Get an available readback buffer from the ring Generate mesh for a chunk on the GPU using a specific buffer set Legacy meshChunk uses first buffer set (for backwards compatibility) Create a fresh indirect draw buffer for a chunk (for true indirect rendering) This allows each chunk to have its own indirect buffer for parallel rendering Allocate a slot in the batched indirect buffer for a chunk Free a slot in the batched indirect buffer Update draw parameters for a chunk in the batched buffer Get the byte offset for a chunk's slot in the batched buffer Get the batched indirect buffer for rendering Render all batched chunks with a single sequence of indirect draws This is 300× faster than individual indirect buffers on Windows/D3D12! Destroy GPU resources Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks


voxel/VoxelMeshCompute.js

HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelMesher.js

getChunkOcclusionMask(getNeighborChunk, cx, cy, cz)

getViewCullingMask(cx, cy, cz, cameraPos)

meshChunk(chunk, getNeighborVoxel = null, occludedFaces = 0)

meshChunkLOD(chunk, lodLevel = 0, getNeighborVoxel = null, neighborLODs = null)

meshChunkGreedy(chunk, getNeighborVoxel = null)

meshSubChunk(chunk, subSize, sx, sy, sz, getNeighborVoxel = null)

async meshSubChunk4GPU(chunk, sx, sy, sz)

async meshSubChunk8GPU(chunk, sx, sy, sz)

getMeshGranularity(distance, hasRecentModifications = false, modCount = 0)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Check if a material is transparent Check if a chunk's boundary face is fully solid (all voxels on that face are non air) Used to skip meshing faces that are completely hidden by a solid neighbor Parameters: (VoxelChunk) — No description in source JSDoc. (number) — FACE RIGHT, FACE LEFT, etc. Returns: true if the entire boundary face is solid Get occlusion mask for a chunk based on neighbor chunk boundaries Returns a bitmask where bit N is set if face N is fully occluded Parameters: (Function) — Function(cx, cy, cz) returning neighbor chunk (number) — Chunk X coordinate (number) — Chunk Y coordinate (number) — Chunk Z coordinate Returns: Bitmask of occluded faces Get view dependent face culling mask Skips chunk faces that face away from camera (backface culling at chunk level) Parameters: (number) — Chunk X coordinate (number) — Chunk Y coordinate (number) — Chunk Z coordinate (number[]) — Camera world position [x, y, z] Returns: Bitmask of faces to skip (facing away from camera) Generate mesh for a voxel chunk using simple per face meshing with AO Returns separate meshes for opaque and transparent (water) geometry Parameters: (VoxelChunk) — No description in source JSDoc. (Function) — Function to get voxel from neighbor chunks (number) — Bitmask of faces to skip (from getChunkOcclusionMask) Returns: {{ Generate mesh using greedy meshing (fewer quads, better performance) Note: Currently does not separate water falls back to simple meshing for chunks with water Parameters: (VoxelChunk) — No description in source JSDoc. (Function) — Function to get voxel from neighbor


voxel/VoxelMesher.js

falls back to simple meshing for chunks with water Parameters: (VoxelChunk) — No description in source JSDoc. (Function) — Function to get voxel from neighbor chunks Returns: } Create GPU buffers for chunk mesh (both opaque and water) Parameters: (GPUDevice) — No description in source JSDoc. (VoxelChunk) — No description in source JSDoc. Mesh a sub region of a chunk (8³ or 16³) Used for ultra fast partial updates in cascaded chunk architecture Parameters: (VoxelChunk) — Parent 32³ chunk (number) — Sub chunk size (8 or 16) (number) — Sub chunk X index (0 3 for 8³, 0 1 for 16³) (number) — Sub chunk Y index (number) — Sub chunk Z index (Function) — Function to get voxel from neighbor chunks Returns: } Initialize GPU sub chunk meshing Parameters: (GPUDevice) — WebGPU device Check if GPU sub chunk meshing is available Mesh a 4³ sub chunk on GPU (10× faster than CPU) Parameters: (VoxelChunk) — Parent chunk (number) — Sub chunk X offset (0 7) (number) — Sub chunk Y offset (0 7) (number) — Sub chunk Z offset (0 7) Returns: } Mesh an 8³ sub chunk on GPU (10× faster than CPU) Parameters: (VoxelChunk) — Parent chunk (number) — Sub chunk X offset (0 3) (number) — Sub chunk Y offset (0 3) (number) — Sub chunk Z offset (0 3) Returns: } Return GPU sub chunk output buffers to the engine pool. Return GPU buffers to pool for reuse Get GPU sub chunk meshing statistics Get mesh granularity based on distance from camera (4 Tier System) Parameters: (number) — Distance from camera in world units (boolean) — True if chunk was recently modified (number) — Number of recent modifications Returns: Mesh granularity (4, 8, 16, or 32) Constants Re exports <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of


voxel/VoxelMesher.js

Re exports <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelModifyCompute.js

voxel/VoxelModifyCompute.js
Classes
class VoxelModifyCompute
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: VoxelModifyCompute.js GPU Voxel Modification System Now powered by vGPU driver Performs sphere and box removal operations on voxel chunks using compute shaders. Outputs removed voxels for particle spawning. Classes Method Signature Summary Initialize the compute system Remove voxels in a sphere using GPU compute Remove voxels in a box using GPU compute Paint voxels in a sphere using the GPU compute kernel. Apply a sphere edit directly to a persistent GPU resident chunk. This is the interactive path and intentionally does not read the chunk back to CPU memory or produce removed voxel particle records. Synchronize a GPU resident chunk back to its CPU representation for legacy raycasts, CPU meshing, serialization, or diagnostics. Execute the compute shader Destroy GPU resources <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelRaycast.js

raycastVoxels(origin, direction, getVoxel, options = {})

hasVoxelLineOfSight(from, to, getVoxel, options = {})

pickBlock(origin, direction, getVoxel, maxDistance = 10)

traceVoxelPath(origin, direction, getVoxel, maxDistance = 50, options = {})

hasLineOfSightCombined(from, to, obstacles, getVoxel, options = {})

computePixelToRayMatrix(cameraPos, cameraRotation, fovRad, screenWidth, screenHeight)

screenPixelToRay(pixelX, pixelY, pixelToRay, cameraPos)

raycastVoxelsDebug(origin, direction, getVoxel, maxDistance = 100)

triangleVoxelIntersect(a, b, c, voxelMin, voxelMax)

voxelizeMesh(vertices, triangles, resolution, boundsMin, boundsMax)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes GPU accelerated batch voxel raycasting system Use when processing 100+ rays per frame Method Signature Summary Initialize GPU raycast system Perform batch raycast Cleanup GPU resources Functions Raycast through voxel world using DDA algorithm Returns first solid voxel hit along ray Parameters: (number[]) — [x, y, z] ray origin in world coords (number[]) — [x, y, z] normalized direction (Function) — (x, y, z) = material ID or null if unloaded (Object) — Raycast options (number) — Maximum ray distance (default 100) (Function) — (material) = boolean (default: !== AIR) (Set) — Materials to treat as transparent Returns: {position, normal, distance, material, voxelCoord} or null Check line of sight between two points through voxels Returns true if no solid voxels block the path Parameters: (number[]) — [x, y, z] start position (number[]) — [x, y, z] end position (Function) — (x, y, z) = material ID (Object) — Same as raycastVoxels Returns: True if line of sight is clear Block picking raycast from camera with face/placement info Returns both the hit block and the adjacent empty block for placement Parameters: (number[]) — Camera/eye position (number[]) — Look direction (normalized) (Function) — (x, y, z) = material ID (number) — Max pick distance (default 10) Returns: {block: voxelCoord, face: normal, placeAt: voxelCoord, distance} Trace ray through voxels collecting all intersected voxels Useful for beam weapons, explosion rays, etc. Parameters: (number[]) — Ray origin (number[]) — Normalized direction (Function) — (x, y, z) = material ID (number) — Max trace distance (Object) —


voxel/VoxelRaycast.js

rays, etc. Parameters: (number[]) — Ray origin (number[]) — Normalized direction (Function) — (x, y, z) = material ID (number) — Max trace distance (Object) — Additional options Returns: Array of {voxelCoord, material, distance, entryPoint} Create a voxel getter function from ChunkManager Parameters: (ChunkManager) — The chunk manager instance Returns: (x, y, z) = material ID or null Combined LOS check uses voxels AND AABB obstacles Drop in replacement for AIAiming.hasLineOfSight Parameters: (number[]) — Start position (number[]) — End position (Array) — AABB obstacles array (Function) — Voxel getter function (Object) — Additional options Returns: True if line of sight is clear Compute a single matrix that transforms screen pixel coords to world space ray directions. This avoids per pixel matrix multiplications in shaders. Usage: rayDir = normalize((pixelToRay vec4(pixelX, pixelY, 1, 1)).xyz cameraPos) Parameters: (number[]) — Camera world position [x, y, z] (number[]) — Euler angles [pitch, yaw, roll] in radians (number) — Field of view in radians (number) — Screen width in pixels (number) — Screen height in pixels Returns: 4x4 matrix (column major) Generate ray from screen pixel using precomputed pixel to ray matrix Parameters: (number) — Screen X coordinate (number) — Screen Y coordinate (Float32Array) — 4x4 matrix from computePixelToRayMatrix (number[]) — Camera position for ray origin Returns: {origin, direction} Raycast with step counting for performance debugging Parameters: (number[]) — Ray origin (number[]) — Normalized direction (Function) — Voxel getter (number) — Max distance Returns: {hit, steps, distance, ...} Convert step count to heat map color (inferno palette) Parameters: (number) — Number of ray steps (number) — Maximum expected steps (for


voxel/VoxelRaycast.js

steps, distance, ...} Convert step count to heat map color (inferno palette) Parameters: (number) — Number of ray steps (number) — Maximum expected steps (for normalization) Returns: [r, g, b] in 0 1 range Check if a triangle intersects a voxel using separating axis theorem. Based on DeadlockCode's implementation. Parameters: (number[]) — Triangle vertex A [x, y, z] (number[]) — Triangle vertex B [x, y, z] (number[]) — Triangle vertex C [x, y, z] (number[]) — Voxel minimum corner [x, y, z] (number[]) — Voxel maximum corner [x, y, z] Returns: True if triangle intersects voxel Voxelize a triangle mesh into a voxel grid Parameters: (Array) — Array of [x, y, z] vertices (Array) — Array of [i0, i1, i2] index triplets (numbe


voxel/VoxelRenderer.js

voxel/VoxelRenderer.js
Classes
class VoxelRenderer
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Initialize the voxel renderer Compute orthographic light view projection matrix for shadow mapping Compute orthographic water height map matrix (looking down from above) Update frame bind group (called when Hillaire LUT changes) Connect to Hillaire LUT atmosphere system for aerial perspective Create look at view matrix Create orthographic projection matrix (WebGPU: Z maps to [0,1]) Multiply two 4x4 matrices (uses pre allocated buffer) Update frame uniforms (including shadow data, sun, and realm parameters) Update screen size for screen space LOD Get or create resources for a chunk Write chunk uniforms (offset + blend + geomorphing) Write chunk uniform data to batched buffer at given index Flush all batched uniforms to GPU with single writeBuffer call Calculate geomorph factor for smooth LOD transitions Returns 0.0 at LOD boundary start, 1.0 at LOD boundary end Remove resources for a chunk Attach an external ShadowAtlas — the voxel fragment shader will sample from the atlas depth texture instead of the renderer's own shadow map. Call once after init(). The atlas texture must be depth32float. Patch the lightViewProj region of the already uploaded frame uniform buffer. Call AFTER atlas.computeLightMatrix() and AFTER updateFrameUniforms(). This overwrites floats [48..63] (byte offset 192, 64 bytes). Flush voxel chunk shadow depth into an EXISTING render pass. Conforms to the ShadowAtlas caster interface: { flush(pass, lightViewProj) }. Updates the internal shadow uniform buffer with the supplied lightViewProj so voxel shadow pipelines use the correct


voxel/VoxelRenderer.js

interface: { flush(pass, lightViewProj) }. Updates the internal shadow uniform buffer with the supplied lightViewProj so voxel shadow pipelines use the correct light matrix. Render shadow pass renders all chunks to shadow map from light's perspective. Additional casters (entities, particles, ropes) can render into the same shadow depth map so their shadows appear on voxel terrain. Render water surfaces to depth texture for caustic calculation Calculate LOD level (0 9) for a chunk based on distance Returns true 10 level LOD for gradual detail reduction Step sizes: [1, 1, 2, 2, 3, 3, 4, 5, 6, 8] Uses hysteresis to prevent rapid LOD switching (popping): Switching to LOWER detail (higher LOD ) requires 10% MORE distance Switching to HIGHER detail (lower LOD ) requires 10% LESS distance For out of view chunks, only half are allowed to shift LOD per frame (based on chunk position parity) to spread out transitions. Get the fine grained LOD level (0 9) for a chunk (same as getChunkLOD now) Porcupine culling: check if a chunk is completely surrounded by solid neighbors A chunk with all 6 neighbors being solid/opaque cannot be seen from any direction Check if a chunk has any opening (non solid face) on a specific side Cave portal culling: BFS from camera to find all reachable chunks through openings Chunks not reachable from the camera's position are culled Project a world point to screen space (pixels). Returns null if behind camera. Screen space LOD based on projected chunk size (with hysteresis). Hybrid LOD: combine screen space and distance, pick the more detailed (lower) LOD. Render voxel chunks with LOD support GPU driven render using indirect draw commands Uploads all chunks to GPU, runs compute culling, then uses drawIndexedIndirect Set ChunkCullCompute reference for GPU


voxel/VoxelRenderer.js

render using indirect draw commands Uploads all chunks to GPU, runs compute culling, then uses drawIndexedIndirect Set ChunkCullCompute reference for GPU driven rendering Full GPU indirect rendering uses drawIndexedIndirect for maximum GPU efficiency Requires all chunks to be in a unified vertex pool (VertexPool) Render chunks using face pull pipeline (ultra compressed: 4 bytes/face!) Uses vertex pulling from storage buffer no vertex/index buffers needed Render water using face pull pipeline Get or create face pull bind group for a chunk (opaque faces) Get or create face pull bind group for water faces Release face pull resources for a chunk Render water/transparent geometry (call AFTER render()) Uses sepa


voxel/VoxelSdfBrickBridge.js

voxel/VoxelSdfBrickBridge.js
Classes
class VoxelSdfBrickBridge
Functions
buildVoxelSdfBrickPair(options = {})
voxelSdfPageToNexel(page, options = {})
createVoxelSdfBrickBridge(options)
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Adapter only: voxel storage and dirty queue ownership remain with the voxel subsystem. Callers pass the dirty entries they already admitted this frame. Method Signature Summary Functions Convert one voxel chunk plus a one voxel neighbor apron into independently generated coarse and fine sampled field pages. The coarse page is an intentionally expanded conservative proxy, so a fine page miss degrades shape accuracy instead of silently removing occupied geometry. <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/VoxelShaders.js

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: VoxelShaders.js WGSL shader strings for VoxelRenderer Extracted from VoxelRenderer.js for modularity Functions Constants <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


voxel/index.js

voxel/index.js
Re-exports
Notes & Examples
Voxel World System

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: engine/voxel/index.js Voxel System Barrel Export Core voxel functionality. Other systems have been moved to: engine/render/passes/ Post processing passes engine/render/atmosphere/ Sky and atmospheric rendering engine/world/ World generation, streaming, storage, time engine/sim/physics/ Physics systems engine/sim/fluids/ Fluid simulation engine/core/gpu/ GPU utilities engine/core/math/ Math utilities engine/core/memory/ Memory management engine/core/profiler/ Profiling engine/game/ Gameplay systems Re exports , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , <! HUMAN NOTES Notes & Examples Voxel World System The voxel system provides chunked 3D grids with fast access, mesh generation, and level of detail (LOD). Chunks are 32³ by default and stream in/out based on camera position. The mesher generates greedy or marching cubes geometry depending on material. Example: Creating and modifying a voxel world See also: Engine Overview


world/FDTDSolver.js

world/FDTDSolver.js
Exports
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/FloatingOrigin.js

shiftObjects(objects, shiftX, shiftY, shiftZ)

shiftPosition(pos, shiftX, shiftY, shiftZ)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Set absolute world position Set position using hierarchical coordinates (planet scale) Get the current hierarchical position Get current sector as [x, y, z] Get current sector key for lookups Get absolute world position (full precision) Get position relative to local origin (for rendering/physics) This is what gets sent to the GPU always near zero for precision Get the current origin offset Convert absolute world coords to local coords Convert local coords back to absolute world coords Register a callback for rebase events Callback receives (shiftX, shiftY, shiftZ) the amounts to subtract from positions Check if rebase is needed and perform it Call this every frame after updating player position Force a rebase to bring local origin to player position Get depth (negative Y in absolute coords) Useful for depth based game mechanics Get depth tier based on absolute Y position Debug info Load configuration from engine.cfg section Enable hierarchical (planet scale) coordinate mode Register callback for sector changes Callback receives (oldSectorKey, newSectorKey, sectorDelta) Internal: Notify sector change listeners Get camera relative position for a world point (GPU safe f32) Uses hierarchical math for precision at any distance Convert hierarchical position to camera relative (GPU safe f32) Check if a sector is within render distance Get all visible sector keys within distance Functions Shift an array of objects by the rebase offset Objects must have x, y, z properties Parameters: (number) — No description in source JSDoc. (number) — No description in


world/FloatingOrigin.js

array of objects by the rebase offset Objects must have x, y, z properties Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Shift a position array [x, y, z] by the rebase offset Parameters: (number[]) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Constants — Distance from local origin at which to trigger a rebase (in world units) — Chunk size for coordinate snapping during rebase — Sector based rebase threshold (rebase when crossing sector boundaries) <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/HierarchicalCoords.js

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Represents a position using sector + local coordinates Sector is integer grid position, local is f32 safe offset within sector Method Signature Summary Normalize coordinates so local stays within [0, SECTOR SIZE) Overflow/underflow adjusts sector accordingly Create from flat world coordinates Convert to flat world coordinates WARNING: May lose precision at extreme distances Get position relative to a reference position (camera/player) Result is f32 safe for GPU upload Get squared distance to another position Uses hierarchical math for precision Get distance to another position Add offset to position Set from another HierarchicalPosition Clone this position Check if in same sector as another position Get sector key for hashing/lookup Get sector as array [x, y, z] Get local position as array [x, y, z] Serialize to transferable object Deserialize from object Debug string representation Extended hierarchical position using BigInt for extreme planet scales Use only when sector coordinates exceed MAX SAFE SECTOR Method Signature Summary Convert to standard HierarchicalPosition if within safe range Functions Get all sector keys within radius of a position Parameters: (HierarchicalPosition) — No description in source JSDoc. (number) — Radius in sectors Returns: Array of sector keys Parse sector key back to coordinates Parameters: (string) — Sector key "x,y,z" Calculate sector aligned chunk key Useful for chunk loading that respects sector boundaries Parameters: (HierarchicalPosition) — No description in source JSDoc. (number) — Size of chunks in world units Convert world


world/HierarchicalCoords.js

that respects sector boundaries Parameters: (HierarchicalPosition) — No description in source JSDoc. (number) — Size of chunks in world units Convert world coordinates to hierarchical Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Convert hierarchical to world coordinates Parameters: (HierarchicalPosition) — No description in source JSDoc. Get camera relative coordinates (f32 safe for GPU) Parameters: (HierarchicalPosition) — Position to convert (HierarchicalPosition) — Camera position Constants — Size of one sector in world units (10km) — Half sector size for boundary checks — Inverse for fast division — Maximum safe integer for sector coords (before BigInt needed) <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/PhasorRays.js

world/PhasorRays.js
Exports
Notes & Examples
World Streaming & Scenes


world/PhotonicCrystal.js

world/PhotonicCrystal.js
Exports
Notes & Examples
World Streaming & Scenes


world/PlanetPhysics.js

world/PlanetPhysics.js
Classes
class DoubleVec3
class Quaternion
class Planet
class PlanetarySystem
Functions
splitDouble(value)
combineDouble(hi, lo)
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Double precision 3D vector using hi/lo split Method Signature Summary Method Signature Summary Method Signature Summary Update planet rotation Get gravity vector at a world position Get gravity as a vec3 Get surface local up vector at a position Convert world position to planet local (rotating frame) Convert planet local to world position Get latitude/longitude from world position Get world position from latitude/longitude/altitude Get surface velocity at a position (from planet rotation) Compute Coriolis acceleration for a moving object Get tangent space basis at a surface point Raycast to planet surface Get GPU uniform data Method Signature Summary Get combined gravity at a position from all planets Find nearest planet to a position Functions Split a double into hi/lo f32 pair for GPU precision Combine hi/lo f32 pair back to double Constants — Gravitational constant (scaled for game) — Default planet radius (180,000 km = 180,000,000 m) — Default planet mass (for Earth like surface gravity) — Default rotation period in seconds (24 hours) — Minimum gravity magnitude (to avoid division issues) <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/PlanetaryCoords.js

planetaryToWorld(face, shell, u, v, planetRadius = DEFAULTPLANETRADIUS)

worldToPlanetary(x, y, z, planetRadius = DEFAULTPLANETRADIUS)

worldToPlanetaryChunk(x, y, z, chunkSize = 32, planetRadius = DEFAULTPLANETRADIUS)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Planetary world configuration Method Signature Summary Toggle planetary mode Get depth tier based on shell (for realm physics) Get gravity strength based on shell (Shell Theorem) Functions ASC (Adjusted Spherified Cube) projection Maps a point on a cube face to a point on a unit sphere Parameters: (number) — Face coordinate U ( 1 to 1) (number) — Face coordinate V ( 1 to 1) Returns: Normalized direction on unit sphere Inverse ASC projection Maps a direction on unit sphere back to cube face coordinates Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: } Convert face coordinates to a direction on the unit sphere Parameters: (number) — Cube face index (0 5) (number) — Face coordinate ( 1 to 1) (number) — Face coordinate ( 1 to 1) Returns: Unit direction vector Convert planetary coordinates to world position Parameters: (number) — Cube face index (number) — Shell index (0 = surface, negative = underground) (number) — Face coordinate ( 1 to 1) (number) — Face coordinate ( 1 to 1) (number) — Planet radius Returns: World position Convert world position to planetary coordinates Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: } Get gravity direction at a world position (points toward center) Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Returns:


world/PlanetaryCoords.js

center) Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: Normalized gravity direction Get "up" direction at a world position (away from center) Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: Normalized up direction Get chunk key for planetary coordinates Parameters: (number) — Face index (0 5) (number) — Shell index (number) — Chunk U coordinate on face (number) — Chunk V coordinate on face Returns: Unique chunk key Parse planetary chunk key Parameters: (string) — No description in source JSDoc. Returns: null} Convert world position to planetary chunk coordinates Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — Size of chunks in world units (number) — No description in source JSDoc. Returns: } Constants <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/SurfaceAttachment.js

world/SurfaceAttachment.js
Classes
class AttachmentPoint
class SurfaceAttachment
class AttachmentManager
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Represents a point on a surface where attachment occurs Method Signature Summary Set from world position on a planet Update world position from planet local (after rotation) Get world position Get surface normal Invalidate (surface destroyed) Manages attachment state for a single entity Method Signature Summary Attach to surface at world position Detach from surface Update attachment physics Apply external force Check if currently attached Get attachment type name Retract grapple Extend grapple Manages attachments for multiple entities Method Signature Summary Create attachment for entity Get attachment for entity Remove attachment Update all attachments Notify surface destruction at a voxel Constants — Attachment types — Break conditions — Default attachment parameters <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/WorldSchema.js

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Get biome type ID from name Get biome type name from ID Validate terrain config Validate weather config Validate world config Create default terrain config Create default weather Create default world config Create climate from biome position Get biome from climate Get weather preset Get time phase for hour Constants — Biome type definitions — Climate parameter ranges (0 1) — Climate schema for biome selection — Biome definition schema — Noise parameters schema — Erosion types — Terrain generation schema — Chunk sizes — Zone types for streaming — Chunk streaming schema — Weather types — Weather schema — Time of day phases — World time schema — Complete world configuration <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/WorldTime.js

world/WorldTime.js
Classes
class GameDate
class HierarchicalTimingWheel
class WorldTimeSystem
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: WorldTime.js Comprehensive Temporal Architecture Implements robust server side time tracking based on: Tick based architecture with 64 bit precision (BigInt) Hierarchical Timing Wheels for O(1) event scheduling Custom calendar system derived from total ticks Timescale ratios (game time vs real time) Offline progression support Network clock synchronization Reference: "Temporal Architecture in Virtual Environments" Classes GameDate A view of the world time as calendar date Never store date components directly always derive from ticks Method Signature Summary Total seconds since epoch Total days since epoch Current year (1 indexed) Day of year (0 indexed) Current season (0 3) Season name Current month (1 indexed) Day of month (1 indexed) Hour of day (0 23) Minute of hour (0 59) Second of minute (0 59) Normalized time of day (0.0 = midnight, 0.5 = noon, 1.0 = midnight) Is it daytime (6:00 18:00)? Is it night (18:00 6:00)? Moon phase (0 7) based on 28 day cycle Moon phase name Moon illumination (0.0 = new, 1.0 = full) Format as string Format as short date Format time only Add ticks and return new date Add days and return new date Compare with another date HierarchicalTimingWheel Multi level timing wheel for efficient scheduling Level 0: Ticks (20 slots = 1 second at 20 TPS) Level 1: Seconds (60 slots = 1 minute) Level 2: Minutes (60 slots = 1 hour) Level 3: Hours (24 slots = 1 day) Level 4: Days (28 slots = 1 month) Method Signature Summary Schedule an event Schedule recurring event Cancel a scheduled event Advance the wheel by one tick and execute due events Cascade events from higher levels to lower levels Find the appropriate wheel level for a delay Get pending event count Get


world/WorldTime.js

by one tick and execute due events Cascade events from higher levels to lower levels Find the appropriate wheel level for a delay Get pending event count Get stats WorldTimeSystem Main time tracking system Features: 64 bit tick precision Configurable timescale Event scheduling via timing wheel Offline progression Network sync support Method Signature Summary Initialize the time system Update the time system call every frame Get current total ticks Get current game time in seconds (float, for rendering) Get current date/time as GameDate Get normalized time of day (0 1) Schedule an event Schedule recurring event Cancel scheduled event Set timescale Pause time Resume time Toggle pause Register callback for offline progression Process offline time (call on load) Save current state Load saved state Synchronize with server time Get synchronized time for network messages Convert game seconds to ticks Convert ticks to game seconds Get ticks until a specific time of day Skip to a specific time Get current state for debugging/UI Load configuration Constants — Tick duration in milliseconds — High precision ticks (100 nanosecond intervals, like .NET DateTime.Ticks) — Timescale presets (game:real ratios) — Calendar configuration — Derived constants — Moon phases — Season names <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/ZoneManager.js

world/ZoneManager.js
Classes
class Zone
class ZoneManager
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Represents a single zone in the world Method Signature Summary Check if a point is inside this zone Point in polygon test using ray casting Get distance to zone boundary (negative = inside) Clamp a point to stay inside the zone Record voxel modification for potential reset Get all voxel modifications Clear modification tracking Manages all zones in the world Method Signature Summary Initialize with system references Create a new zone Remove a zone Get zone at position Get all zones containing a position Update zone states based on player position Check if destruction is allowed at position Record destruction in appropriate zone Reset a battle zone to original state Handle entering a zone Handle exiting a zone Contain particles within their zones Create a battle arena zone Create a safe zone Get zone visualization data for rendering Load configuration from engine.cfg section Constants — Zone types — Zone shapes <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/GPUWorldGenerator.js
Classes
class GPUWorldGenerator
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Acquire an available buffer set for parallel dispatch Release a buffer set back to the pool Constants <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/HydraulicErosion.js
Classes
class HydraulicErosion
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes HydraulicErosion GPU particle based erosion with momentum Method Signature Summary Connect to shared particle system and physics Initialize GPU resources Create dummy vegetation texture (no vegetation) Update params buffer Create compute pipelines Spawn water particles (rain) Run one erosion simulation step Set erosion configuration Reset simulation Get current stats Get stream map buffer for river visualization Stream map stores time averaged particle positions (where water flows) Get pool map buffer for lake visualization Pool map stores water depth at each cell CPU flood fill for lake formation (called when particle stops with volume) Based on Nick McDonald's Procedural Hydrology flood algorithm Update stream map with particle track (time averaged river positions) Destroy GPU resources <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/LayerMap.js
Classes
class LayerMap
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes LayerMap GPU resident stratigraphic terrain data structure Method Signature Summary Initialize GPU resources Update params buffer Create compute pipelines Create core bind group Initialize layer map with bedrock foundation Set world origin for coordinate conversion Set grid scale (world units per cell) Get GPU resources for external use Get material properties Destroy GPU resources Constants <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Connect to wind simulation and particle system Update all active trees with wind Register a tree for wind updates Unregister a tree from wind updates Generate a tree at the given position Generate voxels for a tree Calculate bounding box of tree Place a tree into a chunk's voxel array Get appropriate tree species for a biome Load configuration from config object GPU Grass Instancer Generates millions of grass blades via mesh shaders INTEGRATION: Uses shared particle system for grass blade physics Uses SpatialHashCompute for wind field queries Uses WindSimulation for dynamic wind effects Uses indirect instancing with per blade data generated on GPU: Position jittered from grid Height/width variation Wind animation parameters LOD based on camera distance Method Signature Summary Connect to wind simulation for dynamic grass movement Generate grass blade data for visible patches Get grass type for biome Upload grass blade data to GPU Functions Hash function for position based determinism Constants <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/TectonicSimulation.js
Classes
class TectonicSimulation
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes TectonicSimulation GPU plate tectonics using clustered convection Method Signature Summary Initialize GPU resources Update params buffer Create compute pipelines Initialize segments with random plates Run one simulation step Get heightmap texture for use by other systems Destroy GPU resources <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/ThermalErosion.js
Classes
class ThermalErosion
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ThermalErosion.js GPU Material Specific Talus Angle Erosion Implements thermal erosion (slippage) with: Per material talus angles (angle of repose) Mass conserving material transfer between cells Support for LayerMap stratigraphy Based on: SoilMachine thermal erosion Key concept: If slope tan(θ material), mass transfers downhill Sand: 30° (gentle slopes) Rock: 85° (near vertical cliffs) Classes ThermalErosion GPU material specific talus angle erosion Method Signature Summary Initialize GPU resources Update params buffer Create compute pipelines Run thermal erosion iterations Get current heightmap texture Set material at grid position Set configuration Destroy GPU resources Constants <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: UnifiedTerrainPipeline.js Complete Procedural Geomorphology System Orchestrates the full terrain generation and simulation pipeline: 1. TECTONICS (Initialization Phase) Clustered Convection plate simulation JFA Voronoi for plate boundaries Subduction/collision → bedrock heightmap 2. HYDROLOGY (Real time Simulation) Momentum based particle erosion Meandering river formation Sediment transport & deposition 3. STRATIGRAPHY (LayerMap) Multi layer terrain storage Per material properties Talus angle enforcement 4. THERMAL EROSION (Real time) Material specific slippage Cliff formation Scree slopes Based on: Nick McDonald's research (Clustered Convection, SimpleHydrology, SoilMachine) Classes UnifiedTerrainPipeline Orchestrates all terrain generation systems Method Signature Summary Initialize all GPU resources and sub systems Generate initial terrain using tectonic simulation This is a one time initialization that runs many steps Run one frame of real time erosion simulation Get the current heightmap for rendering Get material map for rendering Get vegetation map Sample terrain height at world position (CPU side, requires readback) For real time use, prefer GPU sampling in shaders Set erosion parameters at runtime Set thermal erosion parameters Get current simulation statistics Reset simulation to initial state Destroy all GPU resources Re exports , , , , , , <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and


indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Set centroids from world positions Generate Voronoi diagram from current centroids Generate procedural detail texture Generate Voronoi from Poisson disc sampling Get Voronoi texture for use in terrain shader Get detail texture for weathering/cracks Get blended texture result Load config from object Functions Sample Voronoi data at a world position (CPU fallback) Parameters: (Array) — Centroid array (number) — World X (normalized 0 1) (number) — World Z (normalized 0 1) Returns: {cellIdx, distance, blendFactor} <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/WindErosion.js
Classes
class WindErosion
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Set wind direction and speed Run one erosion cycle Get sediment buffer for visualization Load config from object <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes Method Signature Summary Initialize the generator Set the world seed Get 5 climate parameters at world coordinates OPTIMIZED: Reduced octaves, uses single noise3D calls where possible Returns: [temperature, humidity, continentalness, erosion, weirdness] Get biome at world coordinates using climate matching Finds the biome whose climate target is closest to the actual climate Get continental value at position (0 = deep ocean, 1 = continental interior) Used for land/ocean distribution and coastal effects Get terrain height at world coordinates with terrain shaping Techniques: continental, tectonic, power redistribution, ridged noise, domain warping Get 3D terrain density at world position OPTIMIZED: Early exit octave evaluation (KdotJPG technique) Only compute 3D noise when height ± max noise range can cross threshold density = 0 = solid, density < 0 = air Check if position is a cave OPTIMIZED: Single noise check first, only compute expensive ridged noise if needed Fast cave check using 4x4x4 low res sampling Samples cave noise at grid points and uses simple threshold 64x faster than full res isCave for deep chunks Get ore type at position (returns null if no ore) Uses depth based ore distribution with vein clustering Check if position should be lava (deep underground pools) Check if position should be underground water Generate a chunk using optimized 3D density function Optimizations: Cache biome/height per column (not per voxel) Fast path for fully underground chunks Reduced noise calls via early exits Inline critical calculations Register a structure generator callback


(not per voxel) Fast path for fully underground chunks Reduced noise calls via early exits Inline critical calculations Register a structure generator callback Generate structures for a chunk (called after terrain) Generate trees in a chunk based on biome Validate that a tree position has solid ground beneath Set tree physics system reference Generate procedural dungeon in underground area Based on: TinyKeepDev algorithm (separation + MST corridors) https://www.gamedeveloper.com/programming/procedural dungeon generation algorithm Carve dungeon into voxel chunk Load configuration from config object Get biome name at world coordinates Get debug info for a position Bake navigation grid from generated terrain Get AI terrain type at world position (for AITerrain.js) Maps voxel materials/biomes to terrain types Get AI movement cost at position (integrates with AITerrain.js) Get cover value at position (for AI combat) Generate heightmap for weather/AI systems Generate watermap for weather system Sample terrain density at world position Negative = inside solid, Positive = outside (air) Ray march through density field to find surface intersection Check sphere collision with terrain Get terrain surface normal at position using gradient of density Sample ambient lighting from terrain at position Combines surface normal, sky visibility, and AO Get lighting influence for an object at position Used for dynamic objects to match terrain lighting Functions Constants <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene


with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/WorldMapGenerator.js
Classes
class WorldMapGenerator
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: WorldMapGenerator.js Full World Map Preview Generator Generates a top down world map from all loaded chunks, similar to Minecraft's world maps. Used for save file previews. Features: Scans all chunks to build a complete heightmap Color codes terrain by material type Height based shading for 3D effect Exports as PNG data URL or blob Classes Method Signature Summary Generate a world map preview from all chunks Calculate world bounds from chunks Build a heightmap from all chunks Returns a Map of "x,z" { material, height } Find the top solid block in a chunk column Render the heightmap to a canvas Add vignette effect Add chunk grid overlay Generate placeholder when no chunks available Generate preview and return as Blob for storage <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/generation/index.js
Re-exports
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Re exports , , , , , , , , , , , <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/index.js

world/index.js
Re-exports
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Re exports , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/storage/ChunkNetworking.js
Classes
class ChunkNetworking
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: Versioned multiplayer chunk synchronization with legacy read compatibility. V1 remains the write format during the expand phase. V1, V2, and the original unversioned response shape can be read, allowing rolling upgrades without relabelling or discarding old traffic. Classes Method Signature Summary Constants — Versioned multiplayer chunk synchronization with legacy read compatibility. V1 remains the write format during the expand phase. V1, V2, and the original unversioned response shape can be read, allowing rolling upgrades without relabelling or discarding old traffic. <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/storage/ChunkPersistence.js
Classes
class ChunkPersistence
Functions
chunkPersistenceCurrentKey(legacyKey)
prepareChunkPersistenceRecord(record)
Constants
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ChunkPersistence.js Chunk Save/Load System Manages chunk persistence with: Multiple save formats (binary, JSON, compressed) Delta saves (only modified blocks) Auto save with configurable interval Backup management Classes Method Signature Summary Initialize persistence system. Start auto save timer. Queue a chunk for saving. Get delta data (only modified blocks). Get full chunk data. Simple RLE compression. Decompress RLE data. Save a chunk using legacy first/current last writes in one transaction. Load a chunk, preferring v2 unless a rollback writer changed v1. Process the save queue for this frame. Functions Validate one exact v1/v2 chunk record without manufacturing an upcast. Constants — ChunkPersistence.js Chunk Save/Load System Manages chunk persistence with: Multiple save formats (binary, JSON, compressed) Delta saves (only modified blocks) Auto save with configurable interval Backup management <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


applyDelta(voxels, modifications, forward = true)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Serialize complete chunk state Parameters: (Object) — Chunk object with voxels, entities, metadata (Object) — Serialization options Returns: Serialized binary data Deserialize chunk from binary data Parameters: (Uint8Array) — No description in source JSDoc. (Object) — No description in source JSDoc. Returns: Chunk object Apply delta modifications to voxel array Parameters: (Uint8Array) — No description in source JSDoc. (boolean) — true = apply new values, false = apply old values (undo) Create chunk key from coordinates Parameters: (number) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — No description in source JSDoc. Parse chunk key to coordinates Parameters: (string) — No description in source JSDoc. Returns: } Get serialized chunk size estimate Parameters: (Object) — No description in source JSDoc. Re exports , , , , , , , , <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/storage/DiskMeshCache.js
Classes
class DiskMeshCache
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes DiskMeshCache IndexedDB backed mesh cache Method Signature Summary Initialize the IndexedDB database Generate cache key for a chunk Check if mesh exists in cache Get mesh from cache Save mesh to cache Immediate save (internal) Add to memory cache with LRU eviction Clear all cached meshes for current world Clear entire cache Clean up old entries Get cache statistics Get stats Set world seed (call when changing worlds) Close database connection Load configuration from engine.cfg section <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/storage/PaletteCompression.js
Classes
class CompressedChunk
class ChunkCompressor
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes CompressedChunk Palette compressed voxel storage Method Signature Summary Compress raw voxel data Decompress to raw voxel data Get voxel at position (without full decompression) Set voxel at position (may trigger recompression) Get compression ratio Serialize for storage/network Deserialize from storage/network ChunkCompressor Manages compression for multiple chunks Method Signature Summary Compress and store a chunk Get compressed chunk Decompress a chunk Remove a chunk Get overall compression ratio Get stats Clear all chunks <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview


world/storage/RLECompression.js
Classes
class RLEChunkCompressor
class HybridChunkCompressor
Functions
encodeColumn(column)
decodeColumn(encoded, expectedLength)
Notes & Examples
World Streaming & Scenes

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Classes RLEChunkCompressor RLE compression for entire chunks Method Signature Summary Compress a chunk using column based RLE Decompress a chunk from RLE format Get a single voxel from compressed data without full decompression Serialize compressed chunk for storage/network Deserialize compressed chunk from storage/network Get compression stats Reset stats Hybrid compression: Palette + RLE First applies palette compression, then RLE on the indices Method Signature Summary Compress chunk using palette + RLE Decompress palette + RLE compressed chunk Functions Encode a single column using RLE Parameters: (Uint8Array) — Voxel data for one column Returns: Compressed data Decode RLE column back to raw data Parameters: (Uint8Array) — No description in source JSDoc. (number) — Expected output length <! HUMAN NOTES Notes & Examples World Streaming & Scenes The world system manages scene graphs, asset streaming, and level transitions. Scenes are entity hierarchies with spatial indexing (BVH) for fast culling and raycasts. Worlds stream assets asynchronously with priority based on distance and visibility. Example: Scene graph and streaming See also: Engine Overview