geo
The mesh builder the Helsinki diorama is modelled with. Accumulates triangles with a colour per vertex into one buffer and returns a runtime mesh, so a whole district draws as a single object.
geo
The mesh builder the Helsinki diorama is modelled with. Accumulates triangles with a colour per vertex into one buffer and returns a runtime mesh, so a whole district draws as a single object.
local Geo = require("game.board.geo")
local b = Geo.new()
b:box(0, 0.5, 0, 2, 1, 2, "#f4efe4", "#d8cbb8")
local handle = b:build()
Primitives: vertex / tri (raw), face, quad, slab, plate, box,
prism, disc, tube, ring, ribbon. Colours are CSS hex strings,
converted to linear light on the way in; hex, mix, shade and shadeHex
work with them. ellipse makes an outline, rng a seeded generator.
Every face helper takes an outward direction and reverses the triangle when the winding disagrees with it, so a face is stated by where it looks.
Consumed by game.board.terrain, game.board.path, game.board.city and
game.board.Board.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2geo — the mesh builder the Helsinki diorama is modelled with. Every part of the board is generated geometry: the peninsula, the water, the streets, the tile slabs, the trees and the little city blocks. This module accumulates triangles with a colour per vertex into ONE buffer and hands back a runtime mesh, so a whole district draws as a single object instead of a hundred entities. local Geo = require("game.board.geo") local b = Geo.new() b:box(0, 0.5, 0, 2, 1, 2, "#f4efe4", "#d8cbb8") local handle = b:build() Colours are CSS hex strings. The mesh carries them as vertex colours and the pbr shader multiplies them into the material's base colour, so one white material paints the whole board. Winding: a triangle's front face is the one whose vertices turn counter-clockwise to the viewer. Every face helper here takes an OUTWARD direction and reverses the triangle when the winding disagrees with it, so a face is stated by where it looks rather than by the order its corners happen to be in.
toLinear(v: number) → number
A vertex colour reaches the shader as a straight multiplier on the material's base colour, which is lit in linear light. A hex colour is written in sRGB, so it is converted here — hand the shader the sRGB number directly and a cream wall arrives at nearly white and blows out.
| arg | type | description |
|---|---|---|
| v | number |
hex(hex: string) → void
"#f4efe4" -> its linear-light r, g, b
| arg | type | description |
|---|---|---|
| hex | string |
mix(a: string, b: string, t: number) → void
Blend two hex colours, t = 0 gives a, t = 1 gives b.
| arg | type | description |
|---|---|---|
| a | string | |
| b | string | |
| t | number |
shade(hex: string, k: number) → void
Lighten (k > 0) or darken (k < 0) a colour, for edges and shading.
| arg | type | description |
|---|---|---|
| hex | string | |
| k | number |
shadeHex(hex: string, k: number) → string
Lighten or darken a colour and hand back a HEX STRING. `shade` works in linear light because that is where a vertex colour is used; this one works in sRGB, so its result can be passed anywhere a hex is taken without being converted to linear a second time.
| arg | type | description |
|---|---|---|
| hex | string | |
| k | number |
new( ) → void
vertex(self: ?, x: number, y: number, z: number, nx: number, ny: number, nz: number, r: number, g: number, b: number, u: number?, v: number?) → number
One vertex. Returns its ZERO-BASED index, which is what `indices` counts in.
| arg | type | description |
|---|---|---|
| self | ? | |
| x | number | |
| y | number | |
| z | number | |
| nx | number | |
| ny | number | |
| nz | number | |
| r | number | |
| g | number | |
| b | number | |
| u | number? | |
| v | number? |
tri(self: ?, a: number, b: number, c: number) → void
| arg | type | description |
|---|---|---|
| self | ? | |
| a | number | |
| b | number | |
| c | number |
face(self: ?, pts: { { number } }, hex: string, ox: number, oy: number, oz: number) → void
A flat polygon, given as an array of {x, y, z} points in order around its rim, painted `hex`, looking the way (ox, oy, oz) points. Fan-triangulated from the first point, so the outline must be convex or near it.
| arg | type | description |
|---|---|---|
| self | ? | |
| pts | { { number } } | |
| hex | string | |
| ox | number | |
| oy | number | |
| oz | number |
quad(self: ?, a: { number }, b: { number }, c: { number }, d: { number }, hex: string, ox: number, oy: number, oz: number) → void
A quad, same contract as `face`.
| arg | type | description |
|---|---|---|
| self | ? | |
| a | { number } | |
| b | { number } | |
| c | { number } | |
| d | { number } | |
| hex | string | |
| ox | number | |
| oy | number | |
| oz | number |
slab(self: ?, x0: number, z0: number, x1: number, z1: number, y: number, hex: string) → void
A flat, up-facing rectangle in the XZ plane.
| arg | type | description |
|---|---|---|
| self | ? | |
| x0 | number | |
| z0 | number | |
| x1 | number | |
| z1 | number | |
| y | number | |
| hex | string |
plate(self: ?, cx: number, cz: number, sx: number, sz: number, y: number, yaw: number, r: number, g: number, b: number) → void
A flat, up-facing rectangle turned `yaw` degrees about Y and painted with a colour already in linear light — for ground that is tinted from a computed value rather than from a named one.
| arg | type | description |
|---|---|---|
| self | ? | |
| cx | number | |
| cz | number | |
| sx | number | |
| sz | number | |
| y | number | |
| yaw | number | |
| r | number | |
| g | number | |
| b | number |
box(self: ?, cx: number, cy: number, cz: number, sx: number, sy: number, sz: number, topHex: string, sideHex: string?, yaw: number?) → void
A box centred on (cx, cy, cz), optionally turned `yaw` degrees about Y. The top gets `topHex`, the four walls `sideHex` (defaults to the top).
| arg | type | description |
|---|---|---|
| self | ? | |
| cx | number | |
| cy | number | |
| cz | number | |
| sx | number | |
| sy | number | |
| sz | number | |
| topHex | string | |
| sideHex | string? | |
| yaw | number? |
p(dx: number, dy: number, dz: number) → void
| arg | type | description |
|---|---|---|
| dx | number | |
| dy | number | |
| dz | number |
dir(dx: number, dz: number) → void
| arg | type | description |
|---|---|---|
| dx | number | |
| dz | number |
prism(self: ?, outline: { { number } }, y0: number, y1: number, topHex: string, sideHex: string?) → void
Extrude a closed outline (an array of {x, z}) from y0 up to y1: a cap on top, a wall down every edge. The outline may run either way round.
| arg | type | description |
|---|---|---|
| self | ? | |
| outline | { { number } } | |
| y0 | number | |
| y1 | number | |
| topHex | string | |
| sideHex | string? |
ellipse(cx: number, cz: number, rx: number, rz: number, seg: number, phase: number?) → void
A regular outline of `seg` points around an ellipse — the input `prism`, `disc` and the tree crowns are all built from.
| arg | type | description |
|---|---|---|
| cx | number | |
| cz | number | |
| rx | number | |
| rz | number | |
| seg | number | |
| phase | number? |
disc(self: ?, cx: number, cz: number, rx: number, rz: number, y: number, seg: number, hex: string) → void
A flat up-facing ellipse at height y.
| arg | type | description |
|---|---|---|
| self | ? | |
| cx | number | |
| cz | number | |
| rx | number | |
| rz | number | |
| y | number | |
| seg | number | |
| hex | string |
tube(self: ?, cx: number, cz: number, y0: number, y1: number, r0: number, r1: number, seg: number, topHex: string, sideHex: string?) → void
A cylinder / cone / truncated cone standing on the Y axis. r1 = 0 makes a spire; r1 = r0 a plain post.
| arg | type | description |
|---|---|---|
| self | ? | |
| cx | number | |
| cz | number | |
| y0 | number | |
| y1 | number | |
| r0 | number | |
| r1 | number | |
| seg | number | |
| topHex | string | |
| sideHex | string? |
ring(self: ?, cx: number, cy: number, cz: number, radius: number, thick: number, seg: number, rings: number, hex: string) → void
A torus lying flat in the XZ plane — the wedding rings on tile 22.
| arg | type | description |
|---|---|---|
| self | ? | |
| cx | number | |
| cy | number | |
| cz | number | |
| radius | number | |
| thick | number | |
| seg | number | |
| rings | number | |
| hex | string |
ribbon(self: ?, path: { { number } }, width: number, y: number, hex: string) → void
A flat ribbon of constant width laid along a path of {x, z} points: the streets, the tram route and the quays are all this.
| arg | type | description |
|---|---|---|
| self | ? | |
| path | { { number } } | |
| width | number | |
| y | number | |
| hex | string |
isEmpty(self: ?) → boolean
| arg | type | description |
|---|---|---|
| self | ? |
build(self: ?) → void
Upload what has been built and hand back the MeshHandle a Model takes.
| arg | type | description |
|---|---|---|
| self | ? |
rng(seed: number) → void
A small deterministic generator, so the same board is dressed the same way on every load and on every machine.
| arg | type | description |
|---|---|---|
| seed | number |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
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.