encodeState()
Pack a generator, its parameters and a seed into a shareable code: URL-safe base64, typically a few dozen characters. Only the declared params travel, each clamped and snapped to its spec, so a value off the step grid decodes to the nearest step.
function encodeState<P>(gen: EntityGenerator<P>, state: Omit<GeneratorState<P>, "generator" | "version">): string;Defined in: engine/src/share.ts:241
Type Parameters
Parameters
| Parameter | Type | Description |
|---|---|---|
gen | EntityGenerator<P> | - |
state | Omit<GeneratorState<P>, "generator" | "version"> | The seed (as an unsigned 32-bit integer) and the parameters. |
Returns
string
The code; decodeState turns it back into the state.
Example
const code = encodeState(broadleafGenerator, { seed: 42, params: broadleafGenerator.defaults });
const tree = generateFromState(decodeState(code));decodeState()
Unpack a code. The generator must be registered, since decoding starts from its defaults and only the declared parameters travel in the code.
entityMaterials()
Material block for a single entity placed at slotMin, the material twin of entityPalette. Undefined when no role declares a hint, so the renderer keeps its cheaper flat-palette path.