pcg-ts examples

Deterministic procedural content generation — graphs, fields, spawners, and the hierarchical runtime, rendered with three.js. Every demo re-cooks live from its seed.

01 Scatter basic
Uniform scatter in bounds, density from a JSON fbm field, probabilistic filtering, instanced boxes + debug points.
02 Forest
fbm heightfield terrain, surface sampling, slope/treeline filters, and pine/bush instancing split by a per-point species attribute — with a device-resident spawn that composes one matrix buffer per species on the GPU. Falls back to the CPU path without WebGPU.
03 Spline fence
Closed CatmullRom loop sampled by arc length; posts oriented from the tangent attribute, rails as tubes along the curve.
04 Infinite world
Two-level hierarchical World streamed around a flying camera: unbounded landmarks above seamless 20-unit rock cells. A GPU toggle and a `derived specs` checkbox show combinator-authored fields reaching the device — and a panel explaining why nothing fuses into a run here.
05 Fields playground
Svelte panel composing noise fields as live FieldSpec JSON, visualized as a colored heightmap surface.
06 Graph editor
Interactive node editor driven by the registry: palette, pin wiring with real graph validation, schema-driven params, live cook, JSON round-trip.
07 Galaxy
An infinite deterministic spiral galaxy: log-spiral density fields, streamed star cells with nebular dust, and click-to-visit planetary systems — every seed grows a different galaxy.
08 GPU fields
A million points colored by a chunky field expression compiled to a WebGPU compute kernel — CPU/GPU toggle, cook stats, and a live parity readout against the bit-exact CPU reference. Falls back to CPU without WebGPU.
09 GPU world
A streamed world drawn from instance matrices composed on the GPU and never read back — one shared device behind the field evaluator and a WebGPU renderer, with live readouts for retained device buffers and cell churn. Needs WebGPU.