Repository navigation
v2.1.1 — the hairspring stops churning
Two things the visual overhaul in v2.1.0 left behind. No new features — the
app looks and behaves as before, it just costs a lot less per frame and
speaks English when asked to.
Fixed
The hairspring rebuilt its whole mesh every frame
updateHair() created a fresh CatmullRom curve and a whole TubeGeometry
on every frame, discarding the previous one — ~5.7 KB of garbage and ~285
µs per frame, more than the rest of the movement put together, plus a full
GPU buffer re-upload each frame.
The tube grid (121×9 vertices, indices, UVs) is now built once, and only
position and normal are rewritten in place in preallocated
Float32Arrays. The CatmullRom curve is gone entirely: the spiral's shape is
analytic, so it can be evaluated directly at the points needed.
| before | after | |
|---|---|---|
setTime per frame |
394.7 µs | 140.5 µs |
| garbage per frame | 7429 B | 1533 B |
| the hairspring's own share | ~285 µs, ~5.7 KB | ~32 µs, 0 B |
Two supporting decisions: cross-sections are framed from the Z axis
(N = T × Z, B = T × N) rather than by Frenet — the spiral's tangent never
turns vertical, so this is stable, cheaper, and does not twist the section
along the coil; and the bounding sphere is computed once, since the spiral
breathes within fixed bounds.
Verified against the analytic curve at four balance angles: axis, tube
thickness and normal length all match to Float32 precision (~3·10⁻⁸). Two
tests keep it that way — one asserts the geometry object and its buffer
survive a frame while the vertices move, the other that the tube keeps a
constant thickness at any balance angle.
The cage controls named themselves in Ukrainian
The two controls added in v2.1.0 wrote their labels as literals, so they
stayed Ukrainian in English. They now go through i18n. Key parity cannot
catch this — a string written straight into .name() never reaches a
dictionary at all — so a test scans main.js for Cyrillic in .name()
literals, allowing only the language button's own "УКР".
Cage opacity and top plate reset on a language change
Switching language rebuilds the GUI, and that state lived inside the builder
while the cage kept whatever had been applied to it.
68 tests.