Low-poly mesh construction for the Baltic. A transform-stack builder that
accumulates flat-shaded triangles and hands back one runtime GPU mesh.
identity( ) → void
The transform stack
A transform is a 3x3 basis in row-major order followed by a translation:
{ m11,m12,m13, m21,m22,m23, m31,m32,m33, tx,ty,tz }. Composing a local
transform L onto the current M gives basis' = M.basis * L.basis and
t' = M.basis * L.t + M.t, which is the ordinary parent-then-child order.
compose(m: { number }, l: { number }) → void
| arg | type | description |
|---|
| m | { number } | |
| l | { number } | |
builder( ) → any
A fresh builder with an empty triangle list and an identity transform.
push(self: ?) → void
Push the current transform so a later `pop` restores it.
pop(self: ?) → void
Restore the transform the matching `push` saved.
translate(self: ?, x: number, y: number, z: number) → void
Move the current transform.
| arg | type | description |
|---|
| self | ? | |
| x | number | |
| y | number | |
| z | number | |
scale(self: ?, x: number, y: number, z: number) → void
Scale the current transform, per axis.
| arg | type | description |
|---|
| self | ? | |
| x | number | |
| y | number | |
| z | number | |
rotateY(self: ?, a: number) → void
Rotate about the local Y axis, in radians.
| arg | type | description |
|---|
| self | ? | |
| a | number | |
rotateX(self: ?, a: number) → void
Rotate about the local X axis, in radians.
| arg | type | description |
|---|
| self | ? | |
| a | number | |
rotateZ(self: ?, a: number) → void
Rotate about the local Z axis, in radians.
| arg | type | description |
|---|
| self | ? | |
| a | number | |
xform(m: { number }, x: number, y: number, z: number) → void
| arg | type | description |
|---|
| m | { number } | |
| x | number | |
| y | number | |
| z | number | |
tri(self: ?, a: { number }, b: { number }, c: { number }) → void
One triangle in local space. `cross(b - a, c - a)` must point out of the
solid; that vector becomes the flat normal all three vertices carry.
| arg | type | description |
|---|
| self | ? | |
| a | { number } | |
| b | { number } | |
| c | { number } | |
quad(self: ?, a: { number }, b: { number }, c: { number }, d: { number }) → void
One quad, as two triangles. `a b c d` run around the face in the order
that makes `cross(b - a, c - a)` point out of the solid.
| arg | type | description |
|---|
| self | ? | |
| a | { number } | |
| b | { number } | |
| c | { number } | |
| d | { number } | |
box(self: ?, cx: number, cy: number, cz: number, sx: number, sy: number, sz: number) → void
An axis-aligned box centred on (cx, cy, cz).
| arg | type | description |
|---|
| self | ? | |
| cx | number | |
| cy | number | |
| cz | number | |
| sx | number | |
| sy | number | |
| sz | number | |
ring(r: number, segs: number, y: number) → void
A ring of points around +Y, wound so a side quad built low-then-high faces out.
| arg | type | description |
|---|
| r | number | |
| segs | number | |
| y | number | |
cylinder(self: ?, y0: number, y1: number, r0: number, r1: number, segs: number, capLow: boolean, capHigh: boolean) → void
A cone/cylinder along +Y between two heights, tapering from `r0` to `r1`.
| arg | type | description |
|---|
| self | ? | |
| y0 | number | |
| y1 | number | |
| r0 | number | |
| r1 | number | |
| segs | number | |
| capLow | boolean | |
| capHigh | boolean | |
sphere(self: ?, r: number, rings: number, segs: number) → void
A faceted sphere — few enough rings and segments that it reads as cut
stone rather than as a ball.
| arg | type | description |
|---|
| self | ? | |
| r | number | |
| rings | number | |
| segs | number | |
loft(self: ?, sections: { any }, capStart: boolean, capEnd: boolean) → void
Loft a run of cross-sections along +Z. Each section is
`{ z = number, pts = { {x, y}, ... } }` with the same point count everywhere
and the points wound counter-clockwise in XY.
| arg | type | description |
|---|
| self | ? | |
| sections | { any } | |
| capStart | boolean | |
| capEnd | boolean | |
panel(self: ?, pts: { { number } }, thickness: number) → void
Extrude a counter-clockwise XY polygon along Z into a slab of `thickness`,
centred on the current origin. Sails, rift shards and signboards are these.
| arg | type | description |
|---|
| self | ? | |
| pts | { { number } } | |
| thickness | number | |
disc(self: ?, y: number, r: number, segs: number) → void
A flat horizontal disc at height `y`, facing up.
| arg | type | description |
|---|
| self | ? | |
| y | number | |
| r | number | |
| segs | number | |
annulus(self: ?, y: number, rInner: number, rOuter: number, segs: number) → void
A flat horizontal annulus at height `y`, facing up — the rift's gate ring
and a stone's halo on the water.
| arg | type | description |
|---|
| self | ? | |
| y | number | |
| rInner | number | |
| rOuter | number | |
| segs | number | |
triangleCount(self: ?) → number
How many triangles this builder holds.
signedVolume(self: ?) → number
The signed volume of everything emitted so far. For a closed solid built
with outward winding it is POSITIVE, which is the numeric audit that a new
primitive is not inside out.
mesh(self: ?) → any
Upload everything emitted as one runtime GPU mesh.