worldgen library
Declarative world generation on package:voxel_engine/core.dart: noise,
terrain recipes, biomes, caves, ores, trees and structures, as a
ChunkGenerator.
Classes
- Biome
- One biome: what covers the ground, what grows on it.
- CaveCarver
- Caves carved out of the ground by two 3D noises: cheese caves anywhere in the rock, wider caverns in the deep, and cave mouths near the surface only where the cave noise runs strong. Pure in the position, so a tree or a structure can ask about a cell of another chunk.
- CaveSpec
- The caves of a world.
- ChunkWriter
- One chunk's block array, written in world coordinates. Everything outside the chunk is silently skipped, which is the point: a feature (a tree, a village) is drawn whole by every chunk it touches, and each keeps its own part, so the pieces meet at the borders without any chunk seeing another.
- Climate
- A window of climate a biome claims. Temperature and humidity are noise in -1..1 (temperature drops with altitude); height is the surface height.
- FastNoiseLite Noise
- A web-safe port of FastNoiseLite covering the OpenSimplex2, OpenSimplex2S, Perlin, Value, and Cellular noise types with None/FBm/Ridged/PingPong fractal layering, plus domain warp (domainWarp2/domainWarp3).
- Ore
- An ore of a world.
- OreTable
- Ores by depth. A cell of 2 x 2 x 2 blocks rolls one vein, and a per-block roll thins it to fill per cent, so ore comes in clumps rather than specks.
- OreVein
- One ore of an OreTable.
- Plant
- A small plant on a biome's surface.
- ScatterGrid
-
At most one feature per patch x patch square, placed by hash, never
closer than inset to the square's border. Two features of one grid
therefore stand at least
2 * inset + 1blocks apart, and every chunk agrees where each one is from the position alone. - SpecGenerator
- A WorldGenSpec compiled for one seed against one game's block ids: the ChunkGenerator the worker isolates run, and the queries a game asks of its terrain (a spawn point, the biome under the player, the structures on the map). Pure in (seed, position), so every isolate agrees.
- StructureGrid
- One structure candidate per region of regionChunks x regionChunks chunks, rolled from the region's hash, so every chunk agrees where it is. A chunk asks the 3 x 3 regions around it, because a structure near a region border reaches into its neighbours.
- StructureSite
-
What a StructureBuild draws with: a site in the world and the chunk being
generated. Coordinates are relative to the site (x, y, z) — the
surface, or
depthunder it — and every write outside the chunk is dropped, so the builder draws the whole structure every time and each chunk keeps its own part. - StructureSpec
- A structure of a world: at most one per region of regionChunks square, in chance of the regions, on the land biomes named in biomes (any land when null), built by build around a site on the surface.
- TerrainRecipe
- How high the ground stands: a continental land mask between lowland and highland, rolling hills, ridged mountains inland and rivers carved to just under the sea.
- TreeBlocks
- The blocks a tree is drawn with.
- TreeCanvas
- A scratch volume a tree is drawn on before it is printed into a chunk.
- Trees
-
Tree shapes drawn on a TreeCanvas at the stump (
x,y,z), whereyis the first air cell above the ground.hshis the tree's own roll (a scatter grid's spot hash), so the same tree is drawn in every chunk. - TreeSpec
- A tree a biome grows.
- WorldGenSpec
- A whole world described as data: its terrain, biomes, ores, caves and structures, with blocks named by string. compile turns it into a ChunkGenerator against a game's block ids.
Enums
- CellularDistanceFunction Noise
- How distance to a cell point is measured by NoiseType.cellular.
- CellularReturnType Noise
- What value NoiseType.cellular computes for a query point.
- DomainWarpFractalType Noise
- How successive domain warp octaves are combined.
- DomainWarpType Noise
- The warp algorithm applied by FastNoiseLite.domainWarp2 and FastNoiseLite.domainWarp3.
- FractalType Noise
- How successive noise octaves are combined.
- NoiseType Noise
- The base noise algorithm used by FastNoiseLite.
- TreeShape
-
The tree shapes of
Trees.
Functions
-
floorDiv(
int a, int b) → int -
adivided byb, rounded toward negative infinity: the region or patch a coordinate falls in, negative coordinates included. -
noiseHash2(
int seed, int x, int y) → int Noise -
Bit-exact hashed value for the integer lattice cell (
x,y). -
noiseHash3(
int seed, int x, int y, int z) → int Noise -
Bit-exact hashed value for the integer lattice cell (
x,y,z). -
simplexNoise(
int seed, double frequency, int octaves, [FractalType fractal = FractalType.fbm]) → FastNoiseLite -
OpenSimplex2S noise with
octavesoffractalatfrequency: the layer every height, climate and cave field here is built from. -
smoothstep(
double a, double b, double t) → double -
0 below
a, 1 aboveb, and a smooth S-curve between. -
worldHash(
int seed, int x, int y, int z) → int -
A 32-bit hash of a world position under
seed: the same cell gives the same number on every chunk, isolate and run, which is what lets two chunks agree on a tree or a structure that crosses their border. Features salty(or scalexandzby primes) to draw independent rolls from one position.
Typedefs
- PlacedStructure = ({String name, int x, int y, int z})
- A structure placed in the world: what SpecGenerator.structuresNear answers.
- StructureBuild = void Function(StructureSite site)
- Draws one structure into one chunk.