game.field.field — the needlefield's own maths.
Everything here is pure: index <-> grid, a needle's seat, the straw's
seat, the matrix a single instance needs, where a cast needle comes to
rest, and the run-length encoding the save uses. No engine calls, so the
component above it stays about behaviour and this stays readable.
index(bale: ?, col: ?, row: ?, layer: ?) → void
| arg | type | description |
|---|
| bale | ? | |
| col | ? | |
| row | ? | |
| layer | ? | |
seat(index: ?) → void
Where a needle sits when nobody has touched it, plus the cell it belongs
to. Cached: the field asks this for all 5600 at start and again whenever
a save restores a fallen needle.
strawSeat(seed: ?) → void
GAME.strawSite(seed) picks a bale and a cell and seats the straw at the
cell's FRONT layer. The spec buries it: every needle in front of it has to
come out before it shows. So the field keeps the site's cell and seats the
straw at the far layer of that cell, through the module's own seat maths.
The straw keeps its cell's far needle slot (so that slot's steel is never
drawn and the cell has to be emptied before the straw shows), but it is
DRAWN at the mouth of the hole — the cell's front-layer point, which is
where GAME.strawSite seats it and the only place the bale body leaves it
visible from the aisle.
norm3(x: ?, y: ?, z: ?) → void
Column-major, the layout drawInstanced reads: the first four floats are
the X basis column, then Y, then Z, and the translation is floats
13/14/15. The basis is built directly (never from a quaternion), so a
needle's long axis is exactly the vector it was given.
| arg | type | description |
|---|
| x | ? | |
| y | ? | |
| z | ? | |
mat4(xx: ?, xy: ?, xz: ?, yx: ?, yy: ?, yz: ?, zx: ?, zy: ?, zz: ?, px: ?, py: ?, pz: ?, s: ?) → void
| arg | type | description |
|---|
| xx | ? | |
| xy | ? | |
| xz | ? | |
| yx | ? | |
| yy | ? | |
| yz | ? | |
| zx | ? | |
| zy | ? | |
| zz | ? | |
| px | ? | |
| py | ? | |
| pz | ? | |
| s | ? | |
frame(ax: ?, ay: ?, az: ?, upx: ?, upy: ?, upz: ?, px: ?, py: ?, pz: ?, s: ?) → void
A placement whose local +X points along `axis`, with `up` tilted as close
to the local +Y as it can be. The needle mesh is modelled along +X.
| arg | type | description |
|---|
| ax | ? | |
| ay | ? | |
| az | ? | |
| upx | ? | |
| upy | ? | |
| upz | ? | |
| px | ? | |
| py | ? | |
| pz | ? | |
| s | ? | |
strawFrame(seat: ?, sx: ?, sr: ?) → void
The Last Straw on its own axis: the generated model is long and thin
along its own X, so `sx` scales its length and `sr` its bore, which is
what lets the field draw a straw of the reference's proportions rather
than the mesh's. Only the normal is used for the frame, so the straw
points out of the bale the way a needle does.
| arg | type | description |
|---|
| seat | ? | |
| sx | ? | |
| sr | ? | |
seatMatrix(seat: ?, out: ?, scale: ?) → void
A needle sitting in its bale: along the bale's normal, upright.
| arg | type | description |
|---|
| seat | ? | |
| out | ? | |
| scale | ? | |
restingPlace(index: ?, seat: ?) → void
Where a needle that has been cast away lies on the floor, and at what
angle. Deterministic in the needle's own index, so a restored save puts
every one of them back exactly where it fell.
| arg | type | description |
|---|
| index | ? | |
| seat | ? | |
restingMatrix(px: ?, py: ?, pz: ?, yaw: ?, out: ?, scale: ?) → void
| arg | type | description |
|---|
| px | ? | |
| py | ? | |
| pz | ? | |
| yaw | ? | |
| out | ? | |
| scale | ? | |
jitter(index: ?) → void
A small deterministic jitter so 5600 needles read as packed bristles
rather than a printed grid. Never enough to leave the needle's cell.
needleScale(index: ?) → void
Every needle is its own length. Without this a bale reads as a printed
grid however much the positions jitter.
encode(list: ?) → void
"1-7,9,12-30" — the pulled needle indices, run-length encoded so a heavily
combed save stays a short string.
decodeList(text: ?) → void
addTri(pos: ?, nor: ?, idx: ?, a: ?, b: ?, c: ?, ox: ?, oy: ?, oz: ?) → void
One needle, modelled along +X: a six-sided shaft, a ground point, and a
pierced eye at the buried end. It is the only mesh the field draws — the
5600 copies are instance transforms, never geometry.
| arg | type | description |
|---|
| pos | ? | |
| nor | ? | |
| idx | ? | |
| a | ? | |
| b | ? | |
| c | ? | |
| ox | ? | |
| oy | ? | |
| oz | ? | |
strawGeometry( ) → void
The Last Straw: a hollow hammered-gold tube with a raised band at each end.
ringPoint(x: ?, r: ?, i: ?) → void
| arg | type | description |
|---|
| x | ? | |
| r | ? | |
| i | ? | |