Modular Voxel-World Framework – Sale

  • Package Info
  • Documentation
Voxel

Each voxel is a simple struct containing blockId, lightLevel and flags bits; the least significant bits encode whether the voxel contains liquid or uses a shape override. A voxel occupies 4 bytes, and a typical chunk of 16×16×128 voxels uses ~128 kB of memory.

Chunk

A chunk is a 3‑D grid of voxels of size (chunkSizeX × chunkSizeY × chunkSizeZ) defined in WorldSettingsAsset (defaults 16×128×16). The ChunkHandle stores chunk coordinates, a NativeArray<VoxelData> for voxels, state (Unloaded, Queued, Generating, Meshing, Active, Unloading), meshes and lists used for meshing. The ChunkPool reuses ChunkHandle instances and their voxel buffers to minimise allocations.

The streaming lifecycle is managed by ChunkCoordinator. It keeps a priority‑sorted list of desired chunks around the player, updates states (queue → generate → mesh → active → unload) and schedules generation and meshing jobs based on distance and view distance. A floating origin system in VoxelWorld re‑anchors the world when the player moves far from the origin by shifting all scene objects and publishing a WorldOriginShifted event.