new( ) → Builder
A new empty builder.
slot(b: Builder, name: string) → Soup
The triangle soup for one material slot of `b`, made on first use.
| arg | type | description |
|---|
| b | Builder | |
| name | string | |
tri(s: Soup, a: vector, b: vector, c: vector, col: Colour?, out: vector?) → void
Adds triangle a b c, flipped if needed so it faces along `out`.
| arg | type | description |
|---|
| s | Soup | |
| a | vector | |
| b | vector | |
| c | vector | |
| col | Colour? | |
| out | vector? | |
quad(s: Soup, a: vector, b: vector, c: vector, d: vector, col: Colour?, out: vector?) → void
Adds quad a b c d (in order round its edge), facing along `out`.
| arg | type | description |
|---|
| s | Soup | |
| a | vector | |
| b | vector | |
| c | vector | |
| d | vector | |
| col | Colour? | |
| out | vector? | |
mark(s: Soup) → number
The current triangle count of `s`, to transform what is added after it with `apply`.
apply(s: Soup, mark: number, fn: (vector) → void
Moves every vertex added to `s` since `mark` through `fn`.
| arg | type | description |
|---|
| s | Soup | |
| mark | number | |
| fn | (vector | |
rotY(a: number, pivot: vector?) → void
A rotation about Y by `a` radians around `pivot`, as a vertex function.
| arg | type | description |
|---|
| a | number | |
| pivot | vector? | |
rotZ(a: number, pivot: vector?) → void
A rotation about Z by `a` radians around `pivot`, as a vertex function.
| arg | type | description |
|---|
| a | number | |
| pivot | vector? | |
rotX(a: number, pivot: vector?) → void
A rotation about X by `a` radians around `pivot`, as a vertex function.
| arg | type | description |
|---|
| a | number | |
| pivot | vector? | |
circleLoop(seg: number, phase: number) → void
| arg | type | description |
|---|
| seg | number | |
| phase | number | |
rectLoop(hx: number, hz: number, rc: number, cornerSeg: number) → void
| arg | type | description |
|---|
| hx | number | |
| hz | number | |
| rc | number | |
| cornerSeg | number | |
sweep(s: Soup, L: { LoopPt }, R: number, prof: { { number } }, o: any) → void
Sweep profile { {d, y} } round loop L (base radius R): point = c + dir * (R + d) + y.
Walk the profile so the outside is on the right of travel in (d, y):
bottom inward to outward, up the outside, top outward to inward.
| arg | type | description |
|---|
| s | Soup | |
| L | { LoopPt } | |
| R | number | |
| prof | { { number } } | |
| o | any | |
P(lp: LoopPt, d: number, y: number) → vector
| arg | type | description |
|---|
| lp | LoopPt | |
| d | number | |
| y | number | |
cap(idx: number, up: boolean) → void
| arg | type | description |
|---|
| idx | number | |
| up | boolean | |
lathe(s: Soup, prof: { { number } }, o: any?) → void
A surface of revolution round the Y axis. `prof` is { {radius, y}, ... } walked bottom-centre outward, up the outside and inward over the top. o: seg, phase, col (colour or fn(k, r, y)), offset (vector), sx/sz (stretch), capStart/capEnd.
| arg | type | description |
|---|
| s | Soup | |
| prof | { { number } } | |
| o | any? | |
roundRect(s: Soup, hx: number, hz: number, rc: number, prof: { { number } }, o: any?) → void
A profile swept round a rounded rectangle of half size hx by hz with corner radius rc. `prof` is { {offset, y} } where offset moves the outline outward (negative inward). o: cornerSeg, col, offset, capStart/capEnd.
| arg | type | description |
|---|
| s | Soup | |
| hx | number | |
| hz | number | |
| rc | number | |
| prof | { { number } } | |
| o | any? | |
slab(s: Soup, hx: number, hz: number, y0: number, y1: number, rc: number, bevel: number, o: any?) → void
A beveled block: a rounded rectangle slab from y0 to y1 with its top edge chamfered by `bevel`. o: cornerSeg, col, offset, bottom (bool, close the underside).
| arg | type | description |
|---|
| s | Soup | |
| hx | number | |
| hz | number | |
| y0 | number | |
| y1 | number | |
| rc | number | |
| bevel | number | |
| o | any? | |
box(s: Soup, c: vector, h: vector, col: Colour?) → void
An axis-aligned box centred on `c` with half size `h`.
| arg | type | description |
|---|
| s | Soup | |
| c | vector | |
| h | vector | |
| col | Colour? | |
q(a: vector, b: vector, cc: vector, d: vector, out: vector) → void
| arg | type | description |
|---|
| a | vector | |
| b | vector | |
| cc | vector | |
| d | vector | |
| out | vector | |
extrude(s: Soup, poly: { { number } }, z0: number, z1: number, bevel: number, o: any?) → void
A star-shaped outline (a polygon every point of which sees its centre) in the XY plane, extruded from z0 to z1 with both faces chamfered by `bevel` (a share of the size, 0..0.4). o: col, sideCol, offset.
| arg | type | description |
|---|
| s | Soup | |
| poly | { { number } } | |
| z0 | number | |
| z1 | number | |
| bevel | number | |
| o | any? | |
at(p: { number }, scale: number, z: number) → vector
| arg | type | description |
|---|
| p | { number } | |
| scale | number | |
| z | number | |
starOutline(points: number, r0: number, r1: number, cy: number?) → void
A star outline with `points` tips of radius r1 and inner radius r0, tip up, in the XY plane.
| arg | type | description |
|---|
| points | number | |
| r0 | number | |
| r1 | number | |
| cy | number? | |
tube(s: Soup, pts: { vector }, r: number, o: any?) → void
A round tube of radius r swept along the points `pts` (open path), capped at both ends. o: sides, col.
| arg | type | description |
|---|
| s | Soup | |
| pts | { vector } | |
| r | number | |
| o | any? | |
voxels(s: Soup, cells: { [string]: Colour }, size: number, origin: vector) → void
Voxels: `cells` maps "x,y,z" (integer cell coordinates) to a colour; only faces between a filled cell and an empty one are drawn. Cell (x,y,z) spans origin + (x..x+1, y..y+1, z..z+1) * size.
| arg | type | description |
|---|
| s | Soup | |
| cells | { [string]: Colour } | |
| size | number | |
| origin | vector | |
key(x: number, y: number, z: number) → string return x
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
qk(v: vector, sc: number) → string
Finish
| arg | type | description |
|---|
| v | vector | |
| sc | number | |
finishSoup(sp: Soup, opts: any?) → any
Welds one soup into mesh arrays { positions, normals, uvs, colors, indices }. opts: angle (crease in degrees, default 35), flat (face normals only), push (move every vertex out along its normal by this many metres, for outline shells).
| arg | type | description |
|---|
| sp | Soup | |
| opts | any? | |
finish(b: Builder, opts: any?) → void
Welds every slot of `b`: answers { [slot] = geometry } plus `order`, the slots in the order they were first used. opts as finishSoup, or opts.perSlot[slot] for one slot.
| arg | type | description |
|---|
| b | Builder | |
| opts | any? | |
bounds(b: Builder) → void
The lowest and highest corner of everything in `b`.
| arg | type | description |
|---|
| b | Builder | |