build
Turns level data into a playable level: floors, walls, water, trees, props and markers merged into one runtime mesh per surface (UVs at each material's real tile size), one CompoundCollider of merged boxes (plus a HeightfieldCollider for the island), point lights for torches, cry…
procLevelKit.build
Turns level data into a playable level: floors, walls, water, trees, props and markers merged into one runtime mesh per surface (UVs at each material's real tile size), one CompoundCollider of merged boxes (plus a HeightfieldCollider for the island), point lights for torches, crystals, start and exit, and loot chests as separate entities so each can be taken. Everything is temporary and unsynced under one root, so every peer builds the same level locally and clear() removes all of it. Returns the level handle (cellToWorld, startPosition, spawnPoints, lootPoints, isAtExit, takeLoot, setTheme, onClear, clear). A surface whose library material has not arrived yet (on the web, collections can still be loading) is drawn in its theme colour meanwhile, and the handle rebuilds its look as soon as the material resolves (materialWait seconds, default 120). B.materialSource swaps the material library. Called by ProcLevel.build / ProcLevel.generate.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2procLevelKit.build: a level's data -> things you can see, walk on and bump into. Floors, walls, water and every prop are appended into one merged runtime mesh per surface (`renderer.mesh.create`), with UVs at each material's real tile size. Collision is one CompoundCollider of merged boxes (greedy rectangles), plus a HeightfieldCollider for the island's rolling ground. Everything is spawned temporary and unsynced under one root: every player builds the same level locally from the same data, nothing goes over the network, and clearing the root removes every trace of it.
defaultMaterialSource( ) → any
Where theme material ids are looked up: the materialLibraryKit library. Swappable (`B.materialSource = function() return myLibrary end`) for a game with its own library, and by the tests.
resolveSurface(theme: Themes.Theme, role: string) → Surface
| arg | type | description |
|---|---|---|
| theme | Themes.Theme | |
| role | string |
lookup( ) → Surface
clearCache( ) → void
rects(W: number, H: number, pred: (number, number) → void
Greedy rectangles over cells where pred(x, y) holds: row runs, then grown down.
| arg | type | description |
|---|---|---|
| W | number | |
| H | number | |
| pred | (number, number |
floorRole(kind: string, ch: string) → string
Which surface the floor of a cell wears.
| arg | type | description |
|---|---|---|
| kind | string | |
| ch | string |
vec(t: any) → void
| arg | type | description |
|---|---|---|
| t | any |
child(parent: any, name: string, pos: { number }?) → any
A child entity of the level: temporary (never saved into a scene) and unsynced (every peer builds its own copy from the same data).
| arg | type | description |
|---|---|---|
| parent | any | |
| name | string | |
| pos | { number }? |
build(L: G.Level, opts: BuildOpts?) → any
| arg | type | description |
|---|---|---|
| L | G.Level | |
| opts | BuildOpts? |
get(x: number, y: number) → string
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
cornerAt(i: number, j: number) → number return cornerH
| arg | type | description |
|---|---|---|
| i | number | |
| j | number |
cellHeight(x: number, y: number) → number
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
mb(role: string) → any
| arg | type | description |
|---|---|---|
| role | string |
light(x: number, y: number, z: number, color: { number }, intensity: number, radius: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number | |
| color | { number } | |
| intensity | number | |
| radius | number |
setBase(h: number) → void
| arg | type | description |
|---|---|---|
| h | number |
face(role: string, x: number, y: number, k: number, y0: number, y1: number, push: number?) → void
face on the edge of cell (x, y) toward direction k, facing outward
| arg | type | description |
|---|---|---|
| role | string | |
| x | number | |
| y | number | |
| k | number | |
| y0 | number | |
| y1 | number | |
| push | number? |
top(role: string, x: number, y: number, h: number, inset: number?) → void
| arg | type | description |
|---|---|---|
| role | string | |
| x | number | |
| y | number | |
| h | number | |
| inset | number? |
tStyle(x: number, y: number) → string
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
wallDir(x: number, y: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
addBox(cx: number, cy: number, cz: number, hx: number, hy: number, hz: number) → void
| arg | type | description |
|---|---|---|
| cx | number | |
| cy | number | |
| cz | number | |
| hx | number | |
| hy | number | |
| hz | number |
addRects(pred: (number, number) → void
| arg | type | description |
|---|---|---|
| pred | (number, number |
dress(e: any, role: string, mesh: any) → void
| arg | type | description |
|---|---|---|
| e | any | |
| role | string | |
| mesh | any |
cellToWorld(self: any, x: number, y: number) → vector
World position of the centre of cell (x, y), standing on its floor.
| arg | type | description |
|---|---|---|
| self | any | |
| x | number | |
| y | number |
worldToCell(self: any, pos: any) → void
The cell a world position falls in.
| arg | type | description |
|---|---|---|
| self | any | |
| pos | any |
startPosition(self: any) → vector
| arg | type | description |
|---|---|---|
| self | any |
exitPosition(self: any) → vector
| arg | type | description |
|---|---|---|
| self | any |
points(self: any, kind: string) → void
| arg | type | description |
|---|---|---|
| self | any | |
| kind | string |
spawnPoints(self: any) → void
Where enemies may appear: { position, cell } for every enemy marker.
| arg | type | description |
|---|---|---|
| self | any |
lootPoints(self: any) → void
Where loot may appear: { position, cell } for every loot marker.
| arg | type | description |
|---|---|---|
| self | any |
isAtExit(self: any, pos: any, radius: number?) → boolean
True when a world position is within `radius` metres (default one cell) of the exit.
| arg | type | description |
|---|---|---|
| self | any | |
| pos | any | |
| radius | number? |
takeLoot(self: any, i: number) → boolean
Take loot chest i (1-based, in marker order) out of the world on this peer.
| arg | type | description |
|---|---|---|
| self | any | |
| i | number |
lootNear(self: any, pos: any, radius: number?) → void
The loot chest nearest a position within `radius`, as index, entry.
| arg | type | description |
|---|---|---|
| self | any | |
| pos | any | |
| radius | number? |
onClear(self: any, fn: () → void
Run `fn` when this level is cleared (enemies, spawn points and anything else a game hangs on the level go with it). Changing the theme is not a clear: the level and what hangs on it stay.
| arg | type | description |
|---|---|---|
| self | any | |
| fn | ( |
teardown(self: any) → void
| arg | type | description |
|---|---|---|
| self | any |
clear(self: any) → void
Remove everything this level built.
| arg | type | description |
|---|---|---|
| self | any |
setTheme(self: any, theme: any) → any
Same layout, another look: rebuilds the visuals with `theme`.
| arg | type | description |
|---|---|---|
| self | any | |
| theme | any |
_watchMaterials(self: any) → void
A surface whose library material was not there when the level was built (on the web the material collections can still be arriving) is drawn in its theme's flat colour meanwhile. This keeps asking for those materials and rebuilds the look as soon as they resolve, so every player ends up seeing the same textured level without doing anything. Gives up after `materialWait` seconds (default 120).
| arg | type | description |
|---|---|---|
| self | any |
Surface = { material: any, tile: number, tint: { number }?, id: string?, fallback: boolean? }BuildOpts = {procLevelKit builder: merged runtime meshes per material, compound box colliders, heightfield for islands, lights, loot entities and the level handle.Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.