voxolith
API reference@voxolith/gen-bushFunctions

generateBush()

Generate a bush: several stems leave the ground together and lean outward (plus satellite clumps for a thicket), branch, carry carved and shaded leaf clumps, thorns, berries or blossom, then anything not connected to the ground is dropped, so the result is one piece. Pure and deterministic in...

function generateBush(
   params: BushParams, 
   rng: () => number, 
   id?: string, 
   ctx?: GenerateContext
): BushResult;

Defined in: bush/src/index.ts:90

Generate a bush: several stems leave the ground together and lean outward (plus satellite clumps for a thicket), branch, carry carved and shaded leaf clumps, thorns, berries or blossom, then anything not connected to the ground is dropped, so the result is one piece. Pure and deterministic in its params and rng.

With ctx.voxelsPerMetre above the native 10 (20, 50 or 100), the same design comes back refined: a sparse model k times the size, stems redrawn from the skeleton.

Parameters

ParameterTypeDefault valueDescription
paramsBushParamsundefinedThe bush; not mutated. Start from a PRESETS entry.
rng() => numberundefinedSource of all randomness, returning 0..1 (e.g. seededRandom(seed)).
id?string"bush"The entity id.
ctx?GenerateContextundefinedOptional scale; omitted or 10 voxels per metre gives the coarse model.

Returns

BushResult

The entity (kind bush, anchored at the centre of its base) and stats.

Example

import { seededRandom } from "@voxolith/renderer/core";
import { cloneParams, generateBush, PRESETS } from "@voxolith/gen-bush";

const p = cloneParams(PRESETS.bramble);
p.look.berryFraction = 0.3;
const { entity } = generateBush(p, seededRandom(3));

On this page