ReadonlyeventsStreaming lifecycle events — chunkLoaded once a chunk's meshes are in the
scene, chunkUnloaded once they're out of it and disposed.
chunks.events.on('chunkLoaded', ({ bounds }) => spawnPropsIn(bounds));
ReadonlychunkTotal number of chunks across the map width
Total number of chunks across the map height
Total number of liquid surface meshes currently in the scene (all types combined).
Number of shore foam meshes currently in the scene (all liquid types combined).
Number of waterfall plunge-pool meshes currently in the scene (all liquid types combined).
Number of waterfall spray particle systems currently in the scene (all liquid types combined).
Currently loaded terrain meshes — pass to pickHexFromMeshes for accurate raycasting.
Changes whenever a terrain chunk is loaded, unloaded, or rebuilt.
Call every frame with the current camera. Loads chunks within loadRadius, unloads those outside.
Mark the chunk containing cell (col, row) as needing a geometry rebuild. Call after modifying map cell data.
Cells on a chunk border also mark the adjacent chunk(s): their shore strips, skirts, bridges, and road geometry sample this cell, so rebuilding only the edited cell's chunk would leave the neighbour's geometry stale.
markDirty for a batch of cells — pairs with MapEdit.cells after undo/redo.
Force-load all chunks (use for small maps or offline baking).
Attach or detach fog-of-war at runtime.
Pass null to disable (vVisibility → 1.0 everywhere).
Replace the scatter definitions and rebuild every loaded chunk's scatter in place — terrain, liquids, and roads are untouched. This is what an editor's scatter builder calls on every change, so it has to be cheap relative to a full chunk rebuild, and it is: instanced meshes only.
Toggle whether unexplored cells are hidden. Independent of dimming.
Toggle whether explored-but-not-visible cells are dimmed. Independent of hide.
Dispose all loaded chunk meshes and their geometries, removing them from the scene.
Does NOT dispose resources the caller passed in and still owns: the terrain material and its texture array, road material, liquid materials, scatter geometries/materials, and any FogData texture. Dispose those yourself when tearing down the scene for good.
Swap in a different HexMap without recreating the manager: all loaded
chunks are unloaded and chunks for the new map stream in on the next
update() (or loadAll()). Materials, terrain definitions, and options
are kept. Water surfaces are recomputed so the new map renders correctly
even if it was edited without a computeWaterSurfaces call.
Swap terrain definitions (and optionally the terrain material) in place —
e.g. after the user defines custom terrain or loads a pack. All loaded
chunks are unloaded and rebuilt with the new definitions on the next
update() / loadAll(); water surfaces are recomputed because liquid
terrain membership may have changed.
The caller keeps ownership of the previous material (dispose it yourself if it is no longer used elsewhere).
Optionalmaterial: Material<MaterialEventMap>Swap the liquid types (descriptors + material sets) in place — e.g. after
the user edits a liquid's appearance or defines a new one. All loaded
chunks are unloaded and rebuilt with the new liquids on the next
update() / loadAll().
The caller keeps ownership of the previous materials (dispose the ones that are no longer used).
Switch the terrain color mode at runtime. Updates the material on all loaded terrain meshes and rebuilds geometry.
Manages the Three.js meshes for a
HexMapusing a chunk-based streaming system.The map is divided into NxN cell chunks.
update(camera)loads chunks withinloadRadiusof the camera each frame and unloads those that have moved out of range. Each chunk is a single mergedBufferGeometrydraw call for terrain, with optional separate meshes per liquid type for surface, shore, estuary, rivers, and waterfall spray/foam, plus roads and scatter features.Call
markDirty(col, row)after modifying map data to trigger a geometry rebuild for the affected chunk on the nextupdate().