voxolith
API reference@voxolith/gen-buildingFunctions

generateBuilding()

Generate a building: the mass (plinth, hollow storeys, roof shell), the window and door layout, then wall texture, trim, openings, roof courses, chimneys and weathering. Rooms are hollow and closed; the front door faces +z. Pure and deterministic in its params and rng.

function generateBuilding(
   params: BuildingParams, 
   rng: () => number, 
   id?: string, 
   ctx?: GenerateContext
): BuildingResult;

Defined in: index.ts:107

With ctx.voxelsPerMetre above the native 10 (20, 50 or 100), the same design is built without its coarse relief and refined on its outside faces only, masonry and joinery redrawn at their real size.

Parameters

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

Returns

BuildingResult

The entity (kind building, anchored at the centre of its footprint at the foot of the plinth) and stats.

Example

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

const p = cloneParams(PRESETS.cottage);
p.shape.storeys = 2;
p.look.lit = 0.5; // dusk
const { entity, stats } = generateBuilding(p, seededRandom(42));

On this page