art/emberward/forge — the hard-surface geometry kit the Emberward is built from.
Everything here returns a plain geometry table:
{ positions = { x,y,z, ... }, normals = { ... }, uvs = { u,v, ... },
colors = { r,g,b,a, ... }, indices = { i0,i1,i2, ... } }
which is exactly what `renderer.mesh.create` takes. Vertex colours matter:
the builtin pbr shader multiplies base colour by the per-vertex colour, so
soot gradients, edge wear and verdigris are baked into the mesh rather than
into a texture. That is what keeps flat plate from reading as flat colour.
Everything is authored in CHARACTER SPACE: metres, feet at y = 0, facing +Z,
the bind-pose figure 1.79 m tall. A piece is glued to a bone afterwards by
the body component, which parents it and cancels the rig's 0.01 bone scale —
so a builder here never thinks about bone axes.
sub(a: ?, b: ?) → void
Vector helpers (plain arrays, no allocation ceremony)
vert(g: Geom, p: { number }, n: { number }, uv: { number }?, c: { number }?) → number
Push one vertex. Returns its index.
| arg | type | description |
|---|
| g | Geom | |
| p | { number } | |
| n | { number } | |
| uv | { number }? | |
| c | { number }? | |
tri(g: Geom, a: number, b: number, c: number) → void
| arg | type | description |
|---|
| g | Geom | |
| a | number | |
| b | number | |
| c | number | |
face3(g: Geom, a: { number }, b: { number }, c: { number }, col: { number }?, flip: boolean?) → void
A flat-shaded triangle.
| arg | type | description |
|---|
| g | Geom | |
| a | { number } | |
| b | { number } | |
| c | { number } | |
| col | { number }? | |
| flip | boolean? | |
merge(dst: Geom, src: Geom) → void
Append `src` into `dst`, re-basing its indices.
| arg | type | description |
|---|
| dst | Geom | |
| src | Geom | |
mergeAll(parts: { Geom }) → Geom
| arg | type | description |
|---|
| parts | { Geom } | |
mirrorX(src: Geom) → Geom
Transforms — applied to a finished geometry, in place
Mirror across x = 0. Winding is reversed so the solid stays solid.
| arg | type | description |
|---|
| src | Geom | |
translate(g: Geom, d: { number }) → Geom
| arg | type | description |
|---|
| g | Geom | |
| d | { number } | |
scale(g: Geom, s: { number }) → Geom
| arg | type | description |
|---|
| g | Geom | |
| s | { number } | |
rotate(g: Geom, axis: { number }, angle: number) → Geom
Rotate about an axis through the origin, angle in radians.
| arg | type | description |
|---|
| g | Geom | |
| axis | { number } | |
| angle | number | |
rot(x: ?, y: ?, z: ?) → void
| arg | type | description |
|---|
| x | ? | |
| y | ? | |
| z | ? | |
paint(g: Geom, fn: (number, number, number) → void
Repaint every vertex from its own position: `fn(x, y, z) -> {r,g,b,a}`.
This is where wear, soot and verdigris are baked in.
| arg | type | description |
|---|
| g | Geom | |
| fn | (number, number, number | |
box(c: { number }, s: { number }, opts: any?) → Geom
Primitives
A bevelled box. `bevel` shaves the twelve edges, which is what stops a
plate reading as a programmer cube: a bevel catches the key light as a
bright line and gives the silhouette a made edge.
| arg | type | description |
|---|
| c | { number } | |
| s | { number } | |
| opts | any? | |
P(sx: ?, sy: ?, sz: ?, ix: ?, iy: ?, iz: ?) → void
Eight inset corner offsets, per axis, so the bevel is a chamfer strip.
| arg | type | description |
|---|
| sx | ? | |
| sy | ? | |
| sz | ? | |
| ix | ? | |
| iy | ? | |
| iz | ? | |
prism(profile: { { number } }, y0: number, y1: number, opts: any?) → Geom
A solid whose cross-section is `profile` (a list of `{x, z}` in the local
XZ plane) swept from y0 to y1, scaled by `scale0` at the bottom and
`scale1` at the top and offset by `lean` at the top. The workhorse for
limb armour, blades, and anything tapered.
| arg | type | description |
|---|
| profile | { { number } } | |
| y0 | number | |
| y1 | number | |
| opts | any? | |
ngon(n: number, phase: number?) → void
A regular n-gon profile of radius 1, usable with `prism`.
| arg | type | description |
|---|
| n | number | |
| phase | number? | |
lathe(profile: { { number } }, segs: number, opts: any?) → Geom
Revolve a profile of `{ radius, y }` points about the Y axis.
| arg | type | description |
|---|
| profile | { { number } } | |
| segs | number | |
| opts | any? | |
shell(opts: any) → Geom
A curved shell plate: the single most useful armour primitive. `f(u, v)`
returns the OUTER surface point for u, v in 0..1; the plate is given a
thickness inwards along its own normal and a rim all the way round, so it
reads as a plate with an edge rather than as a sheet.
| arg | type | description |
|---|
| opts | any | |
surface(grid: ?, normals: ?, flip: ?) → void
Smooth-shaded outer + inner surfaces.
| arg | type | description |
|---|
| grid | ? | |
| normals | ? | |
| flip | ? | |
tube(path: { { number } }, radius: (number) → void
A tube swept along a polyline, with a per-station radius. Straps, chain
links, the cloak's rolled hem, the blade's grip wrap.
| arg | type | description |
|---|
| path | { { number } } | |
| radius | (number | |
noise(x: number, y: number, z: number) → number
Colour helpers — the wear pass
Deterministic value noise in 3D. Same input, same output, every boot — so
the wear on the Emberward's left pauldron is in the same place tomorrow.
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
fbm(x: number, y: number, z: number) → number
Smooth 3-octave noise in 0..1.
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
grid(gx: ?, gy: ?, gz: ?) → void
| arg | type | description |
|---|
| gx | ? | |
| gy | ? | |
| gz | ? | |
smooth(px: ?, py: ?, pz: ?) → void
| arg | type | description |
|---|
| px | ? | |
| py | ? | |
| pz | ? | |
lerp(a: ?, b: ?, t: ?) → void
| arg | type | description |
|---|
| a | ? | |
| b | ? | |
| t | ? | |
wear(opts: any?) → void
The Emberward's standing wear pass, as a `Forge.paint` function factory.
Metal is darkest and sootiest low and at the back (she stands in front of a
furnace), brightest on the high faces the key light finds, and carries a
fine grain everywhere so no facet is one flat value.
| arg | type | description |
|---|
| opts | any? | |