In this section
- Descent geodesy · kuiper-belt / see-through/202611020012/descent.js lines 701–1231
- Kuiper Law render · kuiper-belt / see-through/202611020012/kuiper-law.js lines 1–123
- Kuiper Belt — See Through Page render · kuiper-belt / see-through/index.html lines 1–14
Descent
A JavaScript file in the see through folder of Kuiper Belt that maps wafer meta and sat s, using Web Mercator and haversine, and uses data from the GridAtlas repository.
geodesykuiper-belt / see-through/202611020012/descent.js · lines 701–1231 of 1231 · version 2026-11-02 00:12 (continued from section 1544) · Entry point · pattern nearestToCentre (shared by 2 files)
- What it does
- It maps wafer meta, sat s and l sat. Defines 84 functions or classes, including loadScript, ensureGridData, merc, unmercLat, decode. Side effects: changes the web page (DOM); reads or writes files; makes network requests; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: 400kV, 132kV, 76kV, 27kV, 22kV, 8kV.
- Inputs & outputs
- In: data source: gridatlas data; JSON file style.json; GeoJSON file kv.geojson; JSON file wafer-meta.json; browser storage (getItem). Out: interactive map; canvas drawing. Coordinate systems named: Web Mercator / EPSG:3857. Voltage levels named: 400kV, 132kV, 76kV, 27kV, 22kV, 8kV.
- Downstream impact
- Used directly by 1 file: Kuiper Belt — See Through Page (kuiper-belt, https://ventusltd.github.io/kuiper-belt/see-through/202610050513/).
- What it achieves
- It loads script (`loadScript`), decodes lines (`decodeLines`) and places ui (`placeUI`). `descent.js` SEE THROUGH, a LEARN THE KUIPER module (id 'descent'). Its code works with 400 kV and 132 kV. It reads `../../cosmos/wafer-meta.json`. It responds to pointerdown, pointerenter and pointerleave events.
- Why it matters
- Loaded by the See Through page at https://ventusltd.github.io/kuiper-belt/see-through/202610050513/.
- Application
- kuiper-belt · see-through/202611020012 · script
- VEDIC
- SWITCH (GG2050-VEDIC-000033): See Through / Kuiper · Computer science / Interactive visualisation. view, user_flag → selected_view
- VEDIC
- RISE (GG2050-VEDIC-000034): See Through / Kuiper · Computer science / Interactive visualisation. site, map_state, scene_module → scene_or_refusal
- VEDIC
- SEARCH (GG2050-VEDIC-000030): See Through / Kuiper · Computer science / Interactive visualisation. query, substation_names → match_count_and_indices
- Uses
- GridAtlas — Atlas Page (estate URL), Overlay (estate URL)
- Used by
- loaded by Kuiper Belt — See Through Page (script src)
- Produces
- loadScript, ensureGridData, merc, unmercLat, decode, arr, decodeLines, voltText, opText, nameOf, keyOfSub, bearingOf
- Defines here
- drawLines, rimLights, drawTarget, drawSpider, tower, stageOf, stageCaption, edgeText, caption, networkStatus, attrib, readout, showCard, homeRow, hideCard, arrive, linkText, writeLink, linkFields, readLink, linkKey, linkRepo, rows, cutStars, readSky, once, goHome, btn, lit, pick
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- kuiper-belt@26fba12ab1b5bab8e71934ab86c58273e5f32682 see-through/202611020012/descent.js:701-1231 · blob 5a81bceb9387a56535a99a5111be7c08ea1e4795 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: agent_infra · users: ai_agent · canonical: unknown
var cx = S.cx, cy = S.cy, R = S.Rpx, arm = -S.sw;
if (!S.scan && !S.grab) return;
g.save(); g.translate(cx, cy); g.rotate(arm);
if (S.wedge) { g.fillStyle = S.wedge; g.beginPath(); g.moveTo(0, 0); g.arc(0, 0, R, 0, 0.62); g.closePath(); g.fill(); }
else { for (var k = 0; k < 6; k++) { g.fillStyle = 'rgba(0,255,255,' + (0.025 * (6 - k) / 6).toFixed(3) + ')'; g.beginPath(); g.moveTo(0, 0); g.arc(0, 0, R, k * 0.1, (k + 1) * 0.1); g.closePath(); g.fill(); } }
g.strokeStyle = 'rgba(0,255,255,0.7)'; g.lineWidth = 1.5; g.beginPath(); g.moveTo(0, 0); g.lineTo(R, 0); g.stroke();
g.restore();
// a soft ping when the arm crosses the selected substation
if (S.T >= 0) {
var a = Math.atan2(S.sy[S.T] - cy, S.sx[S.T] - cx), d = a - arm; d -= 6.283185307179586 * Math.floor(d / 6.283185307179586);
if (d < 0.08 && !S.pinged) { S.pinged = true; if (S.D < 7.9) ping(7, 0.02); } else if (d > 0.3) S.pinged = false;
}
}
function drawLines(g, cam, mapA, a) {
var Ls = decodeLines(); if (!Ls) return;
// when GridAtlas's own exact line files are drawing in the map, the simplified lines step back
var ga = (S.mapState === 'ready' && S.gaLines) ? mapA : 0, alpha = a * (1 - ga) * 0.85;
if (alpha < 0.01) return;
var ws = S.D < 2 ? S.wsUK : cam.ws, x0 = S.D < 2 ? S.Cuk[0] : cam.x, y0 = S.D < 2 ? S.Cuk[1] : cam.y, cx = S.cx, cy = S.cy, W = S.W, H = S.H;
var sets = [['grid132', '#00cc00', 1.2], ['grid400', '#0054ff', 2.2]];
g.save(); g.beginPath(); g.arc(cx, cy, S.Rpx, 0, 2 * Math.PI); g.clip();
g.globalAlpha = alpha;
for (var q = 0; q < 2; q++) {
var Lq = Ls[sets[q][0]]; if (!Lq) continue;
var m = Lq.m, seg = Lq.seg, ns = Lq.ns;
g.strokeStyle = sets[q][1]; g.lineWidth = sets[q][2]; g.beginPath();
for (var e = 0; e < ns; e++) {
var A = seg[2 * e], B = seg[2 * e + 1];
var ax = cx + (m[2 * A] - x0) * ws, ay = cy + (m[2 * A + 1] - y0) * ws, bx = cx + (m[2 * B] - x0) * ws, by = cy + (m[2 * B + 1] - y0) * ws;
if ((ax < 0 && bx < 0) || (ax > W && bx > W) || (ay < 0 && by < 0) || (ay > H && by > H)) continue;
g.moveTo(ax, ay); g.lineTo(bx, by);
}
g.stroke();
}
g.restore();
}
function rimLights(g) {
var cx = S.cx, cy = S.cy, R = S.Rpx + 22, n = S.mN, k;
g.save(); g.globalCompositeOperation = 'lighter';
if (n === 1 || S.mTotal === 1) {
var j = S.mIdx[0], a = Math.atan2(S.sy[j] - cy, S.sx[j] - cx), rx = cx + Math.cos(a) * R, ry = cy + Math.sin(a) * R;
var gr = g.createLinearGradient(rx, ry, S.sx[j], S.sy[j]);
gr.addColorStop(0, 'rgba(255,176,0,0.9)'); gr.addColorStop(1, 'rgba(255,176,0,0.15)');
g.strokeStyle = gr; g.lineWidth = 3; g.beginPath(); g.moveTo(rx, ry); g.lineTo(S.sx[j], S.sy[j]); g.stroke();
g.fillStyle = 'rgba(255,176,0,0.95)'; g.beginPath(); g.arc(rx, ry, 7, 0, 2 * Math.PI); g.fill();
g.strokeStyle = 'rgba(255,176,0,0.9)'; g.lineWidth = 2; g.beginPath(); g.arc(S.sx[j], S.sy[j], 12, 0, 2 * Math.PI); g.stroke();
} else {
g.fillStyle = 'rgba(255,176,0,0.55)';
for (k = 0; k < n; k++) {
var i = S.mIdx[k], b = Math.atan2(S.sy[i] - cy, S.sx[i] - cx);
g.beginPath(); g.arc(cx + Math.cos(b) * R, cy + Math.sin(b) * R, 4, 0, 2 * Math.PI); g.fill();
}
}
g.restore();
}
function drawTarget(g, cam) {
var i = S.T, x = S.sx[i], y = S.sy[i], deep = S.D > 4.5;
g.save(); g.strokeStyle = C.amber; g.lineWidth = 2;
// crosshair with a clear middle, so the real compound stays visible under it
var r = deep ? 26 : 12;
g.beginPath(); g.arc(x, y, r, 0, 2 * Math.PI); g.stroke();
if (deep) {
g.lineWidth = 1.5; g.beginPath();
g.moveTo(x - r - 14, y); g.lineTo(x - r + 6, y); g.moveTo(x + r - 6, y); g.lineTo(x + r + 14, y);
g.moveTo(x, y - r - 14); g.lineTo(x, y - r + 6); g.moveTo(x, y + r - 6); g.lineTo(x, y + r + 14); g.stroke();
g.fillStyle = C.amber; g.beginPath(); g.arc(x, y, 1.6, 0, 2 * Math.PI); g.fill();
}
}
function drawSpider(g, cam, now) {
if (!S.spider || S.spider.from !== S.T) { S.spider = buildSpider(); S.spiderT0 = now; spiderCaption(); S.cardDirty = true; }
var sp = S.spider; if (!sp) return;
var cx = S.cx, cy = S.cy, R = S.Rpx, ws = cam.ws, x0 = S.sx[S.T], y0 = S.sy[S.T], t = (now - S.spiderT0) / 1000;
var mpp = 40075016.686 * Math.cos(D0.lat[S.T] * Math.PI / 180) / ws; // metres per screen pixel here
g.save(); g.beginPath(); g.arc(cx, cy, R, 0, 2 * Math.PI); g.clip();
for (var k = 0; k < sp.arrows.length && k < 60; k++) {
var A = sp.arrows[k], tx = cx + (A.mx - cam.x) * ws, ty = cy + (A.my - cam.y) * ws;
var dx = tx - x0, dy = ty - y0, len = Math.sqrt(dx * dx + dy * dy); if (len < 2) continue;
var p = smooth((t - k * 0.15) / 1.1); if (p <= 0) continue;
var ux = dx / len, uy = dy / len, ex = x0 + dx * p, ey = y0 + dy * p;
var colr = A.kv >= 400 ? '#4d8bff' : (A.kv >= 275 ? '#ff5555' : (sp.kind === 'published' ? '#22ee77' : C.amber));
// PYLONS: towers stand up along the arrow as it grows, conductors sag between them (an illustration, not a route)
// towers only on a published overhead circuit; a cable is drawn dashed; a distance arrow carries no towers at all
var gap = S.phone ? 54 : 70, nT = (sp.kind === 'published' && !A.cable) ? Math.min(40, Math.floor(len * p / gap)) : 0;
g.strokeStyle = colr; g.lineWidth = 1.2; g.globalAlpha = 0.85;
var hpx = S.phone ? 16 : 20;
for (var q = 1; q <= nT; q++) tower(g, x0 + ux * gap * q, y0 + uy * gap * q, hpx);
g.beginPath();
var px = x0, py = y0 - hpx * 0.9;
for (q = 1; q <= nT; q++) { var qx = x0 + ux * gap * q, qy = y0 + uy * gap * q - hpx * 0.9; g.moveTo(px, py); g.quadraticCurveTo((px + qx) / 2, (py + qy) / 2 + 7, qx, qy); px = qx; py = qy; }
g.stroke();
// the arrow itself, with an arrowhead where it has reached (spider look: ventus-grid-engine index.html spokes)
g.globalAlpha = 1; g.lineWidth = 2; if (sp.kind !== 'published' || A.cable) g.setLineDash(A.cable ? [10, 6] : [4, 6]);
g.beginPath(); g.moveTo(x0, y0); g.lineTo(ex, ey); g.stroke(); g.setLineDash([]);
g.fillStyle = colr; g.beginPath(); g.moveTo(ex, ey); g.lineTo(ex - ux * 14 - uy * 7, ey - uy * 14 + ux * 7); g.lineTo(ex - ux * 14 + uy * 7, ey - uy * 14 - ux * 7); g.closePath(); g.fill();
if (p > 0.95) {
// label at the far end if it is inside the porthole, otherwise where the arrow meets the rim
var lx = tx, ly = ty, rr = Math.sqrt((tx - cx) * (tx - cx) + (ty - cy) * (ty - cy));
if (rr > R - 40) { var bx = x0 - cx, by = y0 - cy, bb = bx * ux + by * uy, cc = bx * bx + by * by - (R - 50) * (R - 50), s = -bb + Math.sqrt(Math.max(0, bb * bb - cc)); lx = x0 + ux * s; ly = y0 + uy * s; }
g.font = '400 24px ' + FONT; g.textAlign = 'center'; g.textBaseline = 'middle';
var txt = A.label + (A.cable && A.corridor ? ' ROUTE EST ' + (+A.corridor).toFixed(1) + ' KM' : '');
g.fillStyle = '#000'; g.fillRect(lx - g.measureText(txt).width / 2 - 4, ly - 15, g.measureText(txt).width + 8, 30); g.fillStyle = '#fff'; g.fillText(txt, lx, ly);
}
}
void mpp;
g.restore();
}
function tower(g, x, y, h) { // a lattice tower glyph, proportions from TOWER (400 kV class), base at (x, y)
var k = h / TOWER.H, bw = TOWER.base * k * 1.6, top = y - h;
g.beginPath();
g.moveTo(x - bw, y); g.lineTo(x - 1, top); g.lineTo(x + 1, top); g.lineTo(x + bw, y);
g.moveTo(x - bw, y); g.lineTo(x + bw * 0.45, y - h * 0.4); g.moveTo(x + bw, y); g.lineTo(x - bw * 0.45, y - h * 0.4);
for (var a = 0; a < 3; a++) { var zy = y - h * TOWER.armZ[a], al = TOWER.arm[a] * k * 0.9; g.moveTo(x - al, zy); g.lineTo(x + al, zy); }
g.stroke();
}
// ---------------- words on screen ----------------
var STAGES = ['THE KUIPER: A STAR FOR EVERY LINE OF CODE', 'THE STARS GATHER INTO THE GRID', 'ONE REGION', 'ONE SUBSTATION'];
function stageOf(D) { return D < 0.9 ? 0 : (D < 1.95 ? 1 : (D < 3.6 ? 2 : 3)); }
function stageCaption() {
var st = stageOf(S.D);
if (st !== S.stage) {
S.stage = st;
if (!S.flight || st === 3) caption(st === 3 && S.T >= 0 ? 'ONE SUBSTATION: ' + nameOf(S.T).toUpperCase() : STAGES[st]);
S.attDirty = true;
}
var mapShown = S.mapVis ? 1 : 0;
if (mapShown !== S.mapShownC) { S.mapShownC = mapShown; if (mapShown && !S.flight) caption(S.view === 'sat' ? 'THE REAL GROUND, FROM ABOVE' : 'THE REAL MAP'); S.attDirty = true; }
}
var SHORT = { 'SEE THROUGH THE UNIVERSE TO ONE SUBSTATION': 'SEE THROUGH TO ONE SUBSTATION', 'THE KUIPER: A STAR FOR EVERY LINE OF CODE': 'A STAR FOR EVERY LINE OF CODE' };
function edgeText(node, text) {
node.textContent = '';
var words = document.createElement('span'); words.className = 'st-words'; words.textContent = text; node.appendChild(words);
}
function caption(t) {
if (!S) return;
if (S.phone) { t = SHORT[t] || t; if (/^ONE SUBSTATION: /.test(t)) t = 'ONE SUBSTATION'; if (/^DOWN TO /.test(t)) t = 'DOWN TO THE SUBSTATION'; }
edgeText(S.cap, t); S.cap.style.transition = 'none'; S.cap.style.opacity = '1';
clearTimeout(S.capT);
}
function networkStatus(source, failed) {
if (!S) return;
if (!S.failedSources) S.failedSources = {};
if (source) { if (failed) S.failedSources[source] = true; else delete S.failedSources[source]; }
var bad = Object.keys(S.failedSources).length > 0;
S.netNote.textContent = bad ? 'REAL MAP NEEDS THE INTERNET' : '';
S.netNote.style.display = bad && S.D > 1.5 ? 'block' : 'none';
S.attDirty = true;
}
function attrib() {
var t = [], bad = S.failedSources && Object.keys(S.failedSources).length;
if (S.D > 1.5) t.push(ATTR_SUBS);
if (S.D < 1) t.push('Stars placed by the Kuiper law (kuiper-belt@' + KUIPER_LAW_SHA.slice(0, 7) + ', SPACE ' + fmt(S.SPACE) + ')');
if (!bad && (S.mapVis || S.in3d)) { t.push(ATTR_MAP); if (S.view === 'sat' || S.in3d) t.push(ATTR_SAT); if (S.in3d) t.push('Terrain: Terrain Tiles (Tilezen) on AWS; UK terrain (c) Environment Agency copyright and/or database right 2015. All rights reserved'); }
edgeText(S.att, t.join(' · ')); S.att.style.display = t.length ? 'block' : 'none';
S.netNote.style.display = bad && S.D > 1.5 ? 'block' : 'none';
}
function readout(cam) {
var s;
if (S.D < 1) s = fmt(S.NP) + ' STARS KUIPER';
else { var lat = unmercLat(cam.y), mpp = 40075016.686 * Math.cos(lat * Math.PI / 180) / (S.D < 2 ? S.wsUK : cam.ws);
s = 'ZOOM ' + (S.D < 2 ? S.zUK : cam.z).toFixed(1) + ' 1 PX = ' + (mpp >= 1000 ? (mpp / 1000).toFixed(1) + ' KM' : (mpp >= 10 ? Math.round(mpp) : mpp.toFixed(1)) + ' M'); }
if (s !== S.roS) { S.roS = s; S.ro.textContent = s; }
}
function showCard() {
if (S.T < 0 || S.in3d) return;
S.card.textContent = nameOf(S.T) + ' · ' + voltText(S.T);
S.card.title = S.card.textContent;
S.card.style.display = 'block'; S.cardOn = true;
homeRow();
}
// NL-010 5.8 b: the way home by key, a 44 px row of its own directly above the one-line card (the card is an st-edge,
// 24 px high, plain.css:28, so the row cannot live inside it). Made once and only re-labelled, so a tap is never lost
// to a redraw; placed from the card's own box on every showCard.
function homeRow() {
if (!S.homeA) {
S.homeA = el('a', 'position:absolute;display:none;box-sizing:border-box;min-height:44px;line-height:44px;padding:0 12px;background:#000;color:' + C.cyan
+ ';border:1px solid rgba(0,255,255,0.5);border-radius:6px;font:400 14px/42px ' + FONT + ';text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:auto', '', S.ui);
S.homeA.setAttribute('data-st', 'kuiper-key');
S.homeA.addEventListener('pointerdown', function (e) { e.stopPropagation(); });
}
var a = S.homeA, hl = 'STAR KEY ' + fmt(keyOfSub(S.T)) + ' · OPEN IT ON THE KUIPER', hh = KUIPER_URL + '#key=' + keyOfSub(S.T);
if (a.textContent !== hl) a.textContent = hl;
if (a.getAttribute('href') !== hh) a.setAttribute('href', hh);
var cs = getComputedStyle(S.card), ub = S.ui.getBoundingClientRect(), cb = S.card.getBoundingClientRect();
a.style.left = (cb.left - ub.left) + 'px'; a.style.width = cb.width + 'px';
a.style.bottom = (ub.bottom - cb.top + 6) + 'px'; a.style.display = cs.display === 'none' ? 'none' : 'block';
}
function hideCard() { if (S) { S.card.style.display = 'none'; S.cardOn = false; S.cardDirty = S.T >= 0; if (S.homeA) S.homeA.style.display = 'none'; } }
function arrive() { // like the Pipeline News MAP arrival in GridAtlas: on the point, then the card, then the lines
S.cardDirty = true; S.mN = 0; S.mTotal = 0; ping(12, 0.04); ping(19, 0.025);
caption('ONE SUBSTATION: ' + nameOf(S.T).toUpperCase());
if (window.SeeThrough3D && !S.viewTouched) S.auto3d = performance.now() + 1400;
writeLink();
if (S.linkView) { var lv = S.linkView; S.linkView = null; S.auto3d = 0; setView(lv, true); }
}
// ---------------- the deep link (NL-010 step 5.5): read once the names are loaded, and on hashchange ----------------
// key with space is the identity (every substation j has one star key, keyOfSub(j)); sub is a search that lands on the
// first named match; repo lights the stars inside a repository's key ranges; view picks the view after the flight.
function linkText() { return S && S.T >= 0 ? '#key=' + keyOfSub(S.T) + '&space=' + S.SPACE + '&sub=' + encodeURIComponent(D0.names[S.T] || '') : ''; }
function writeLink() { try { if (S && S.T >= 0) history.replaceState(null, '', location.pathname + location.search + linkText()); } catch (e) {} }
function linkFields() {
var h = (location.hash || '').replace(/^#/, ''), f = { bad: [] };
h.split('&').forEach(function (kv) {
if (!kv) return; var i = kv.indexOf('='), k = i < 0 ? kv : kv.slice(0, i), v = i < 0 ? '' : kv.slice(i + 1);
try { v = decodeURIComponent(v.replace(/\+/g, ' ')); } catch (e) {}
if (/^(sub|key|space|repo|view)$/.test(k)) f[k] = v; else f.bad.push(k);
});
return f;
}
function readLink() {
if (!S) return;
var f = linkFields(); S.linkIn = f; S.ring = null; S.repoLit = null; S.repoN = -1; S.linkSub = -1;
S.note.textContent = ''; if (S.T < 0) S.input.value = ''; // a re-read (hashchange) starts clean; every branch that names a substation fills the box again
if (f.repo) linkRepo(f.repo, f);
if (f.key != null) linkKey(f.key, f.space);
// NL-010 team 12: key with space is the identity, sub is a search. When the key names a substation (the link this page
// writes on arrival, #key=..&space=..&sub=..), that substation is flown to, so a name used twice ('Drax' is 1182 and
// 1368) round-trips to the same one; otherwise sub types the name into the box and presses GO.
if (f.sub && S.linkSub >= 0) { S.input.value = D0.names[S.linkSub] || String(f.sub).slice(0, 80); S.note.textContent = ''; S.input.blur(); flyTo(S.linkSub); }
else if (f.sub) { S.input.value = String(f.sub).slice(0, 80); goSearch(); }
if (f.view) { if (!/^(kuiper|map|sat|3d)$/.test(f.view)) f.bad.push('view'); else if (S.flight) S.linkView = f.view; else setView(f.view, true); }
if (f.bad.length && !S.note.textContent) S.note.textContent = 'LINK FIELD ' + String(f.bad[0]).toUpperCase().slice(0, 20) + ' NOT UNDERSTOOD';
}
function linkKey(kv, sv) {
if (!/^\d{1,15}$/.test(kv)) { S.note.textContent = 'LINK FIELD KEY NOT UNDERSTOOD'; return; }
var k = +kv, pre = '';
if (sv != null && !/^\d{1,15}$/.test(sv)) pre = 'LINK FIELD SPACE NOT UNDERSTOOD · '; // named, then ignored (STEPS 5.5)
else if (sv != null && +sv !== S.SPACE && +sv > 0) { // the SPACE remap: any of the 20,000 DRAW THE GRID keys cut under another sky
var sp = +sv, j = Math.floor(k * NRULE / sp), hit = -1;
for (var d = -1; d <= 1; d++) if (j + d >= 0 && j + d < NRULE && Math.floor((j + d + 0.5) * sp / NRULE) === k) hit = j + d;
if (hit >= 0) { pre = 'STAR KEY REMAPPED · SKY ' + fmt(sp) + ' → ' + fmt(S.SPACE) + ' · '; k = Math.floor((hit + 0.5) * S.SPACE / NRULE); }
}
if (k >= S.SPACE) { S.note.textContent = pre + 'KEY ' + fmt(k) + ' IS BEYOND THIS SKY (SPACE ' + fmt(S.SPACE) + ')'; return; }
S.ring = window.KuiperLaw.place(k); // one amber ring at the key's place, for every key on this sky (STEPS 5.5)
for (var i = 0; i < NSUB; i++) if (S.subKey[i] === k) {
S.input.value = D0.names[i] || ''; S.linkSub = i;
S.note.textContent = pre + 'THE STAR THAT LANDS ON ' + nameOf(i).toUpperCase() + '. PRESS GO'; return;
}
S.note.textContent = pre + 'KEY ' + fmt(k) + ' · A LINE OF CODE, NOT A SUBSTATION';
}
function linkRepo(name, f) {
var want = String(name).toLowerCase();
Promise.all(['../../cosmos/repos.tsv', '../../cosmos/wafer.tsv'].map(function (u) {
return fetch(u).then(function (r) { if (!r.ok) throw new Error(u + ' HTTP ' + r.status); return r.text(); });
})).then(function (t) {
if (!S || S.linkIn !== f) return; // a newer link has arrived meanwhile
var rows = function (x) { return x.split('\n').filter(function (l) { return l && l[0] !== '#'; }).map(function (l) { return l.split('\t'); }); };
var rr = rows(t[0]), ri = -1, nm = '';
for (var a = 0; a < rr.length; a++) if (rr[a][1].toLowerCase() === want) { ri = +rr[a][0]; nm = rr[a][1]; }
// then the first name that contains it, as the Kuiper's find box does (editions/202611012027/index.html:612-613)
if (ri < 0 && want) for (a = 0; a < rr.length; a++) if (rr[a][1].toLowerCase().indexOf(want) >= 0) { ri = +rr[a][0]; nm = rr[a][1]; break; }
if (ri < 0) { S.note.textContent = 'NO REPOSITORY CALLED ' + String(name).toUpperCase().slice(0, 40); return; }
var ranges = [], k = 0; // the engine's own walk (kuiper-belt editions/202611012027/index.html:203-208)
rows(t[1]).forEach(function (p) { k += +p[4]; var k0 = k; k += +p[1]; if (+p[2] === ri && k > k0) ranges.push([k0, k]); });
var lit = [], n = S.NP, phoneNow = n < NRULE;
for (var q = 0; q < n; q++) {
var ki = (phoneNow && q >= NSUB) ? NSUB + 2 * (q - NSUB) : q, key = Math.floor((ki + 0.5) * S.SPACE / NRULE);
var lo = 0, hi = ranges.length - 1; while (lo <= hi) { var m = (lo + hi) >> 1; if (key < ranges[m][0]) hi = m - 1; else if (key >= ranges[m][1]) lo = m + 1; else { lit.push(q); break; } }
}
S.repoLit = lit.length ? lit : null; S.repoN = lit.length;
S.note.textContent = lit.length ? nm.toUpperCase() + ' · ' + fmt(lit.length) + ' OF ' + fmt(n) + ' STARS' : 'NO STAR OF THIS SKY FALLS IN ' + nm.toUpperCase();
}).catch(function () { if (S && S.linkIn === f) S.note.textContent = 'REPOSITORY RANGES NEED ../../cosmos/wafer.tsv'; });
}
// the DRAW THE GRID keys under one sky (unchanged arithmetic, moved here from open() so the sky can be re-cut once):
// particle p carries key floor((ki + 0.5) * space / NRULE); substation j's STAR KEY is the key of particle j
function cutStars(space) {
var L = window.KuiperLaw, n = S.NP, phoneNow = S.phoneStars;
S.SPACE = space;
var Rw = Math.sqrt(S.SPACE + 0.5);
for (var p = 0; p < n; p++) {
var ki = (phoneNow && p >= NSUB) ? NSUB + 2 * (p - NSUB) : p, key = Math.floor((ki + 0.5) * S.SPACE / NRULE), pl = L.place(key);
S.kx[p] = pl.x; S.ky[p] = pl.y; S.delay[p] = 0.3 * pl.r / Rw;
var c = Math.floor(p / NSUB); S.pSub[p] = p % NSUB; if (c === 0) S.subKey[p] = key;
var th = c * GA, rr = 2.2 * Math.sqrt(c); S.ox[p] = rr * Math.cos(th); S.oy[p] = rr * Math.sin(th);
}
S.starKey = ''; S.bucketsOK = false;
if (S.cv && S.W) layout();
}
// the Kuiper's address space today, read at run time (ROADMAP step 5.6): the wafer grows every day the engine measures
// it (cosmos/wafer-meta.json address_space), so the sky is re-cut from it while the person is still among the stars and
// nothing has been chosen; the frozen constant of kuiper-law.js is kept when the file cannot be read, or arrives late.
// Calls done() once either way, so the deep link is read under the sky the page will keep.
function readSky(done) {
var once = function () { if (done) { var d = done; done = null; d(); } };
S.spaceSource = 'frozen';
var tm = setTimeout(once, 4000);
fetch('../../cosmos/wafer-meta.json', { cache: 'no-store' }).then(function (r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })
.then(function (m) {
if (!S) return;
var w = +m.address_space; S.waferSpace = w;
if (w === S.SPACE) S.spaceSource = 'wafer-meta';
else if (/^\d{1,15}$/.test(String(m.address_space)) && w > 0 && done && S.T < 0 && !S.flight && S.D < 0.01) { cutStars(w); S.spaceSource = 'wafer-meta'; }
else S.spaceSource = 'frozen (wafer ' + fmt(w) + ')';
S.attDirty = true;
})
.catch(function () {})
.then(function () { clearTimeout(tm); once(); });
}
function goHome() { // the X at the stars stage: back to the Kuiper that opened this page, else its pointer
// the stable link see-through/ is a hop of its own, so the referrer is then the pointer; the pointer keeps the page
// before it in sessionStorage ('seeThroughFrom'). Back only to a same-origin page that is not See Through itself.
var from = document.referrer || '', same = false;
try { if (from && /\/see-through\/(index\.html)?$/.test(new URL(from).pathname)) from = sessionStorage.getItem('seeThroughFrom') || ''; } catch (e) { from = ''; }
try { var fu = new URL(from); same = fu.origin === location.origin && fu.pathname.indexOf('/see-through/') < 0; } catch (e) {}
if (same && history.length > 1) history.back(); else location.href = KUIPER_URL;
}
// ---------------- input ----------------
function btn(label, parent, fn, title) {
var b = el('button', 'pointer-events:auto;font:bold 24px ' + FONT + ';color:' + C.cyan + ';background:transparent;border:1px solid rgba(0,255,255,0.5);border-radius:8px;opacity:0.6;cursor:pointer;white-space:nowrap;letter-spacing:0.5px;transition:opacity .2s,background .2s;touch-action:manipulation', label, parent);
b.type = 'button'; if (title) b.setAttribute('aria-label', title);
b.addEventListener('pointerenter', function () { b.style.opacity = '1'; });
b.addEventListener('pointerleave', function () { if (!b.dataset.on) b.style.opacity = '0.6'; });
if (fn) b.addEventListener('click', function (e) { e.stopPropagation(); audio(); fn(); });
S.allBtns.push(b);
return b;
}
function lit(b, onv) { if (onv) { b.dataset.on = '1'; b.style.background = 'rgba(0,255,255,0.14)'; b.style.opacity = '1'; } else { delete b.dataset.on; b.style.background = 'transparent'; b.style.opacity = '0.6'; } }
function pick(px, py) {
var n = S.D < 2 ? S.NP : NSUB, best = -1, bd = (S.phone ? 34 : 28), bd2 = bd * bd, sx = S.sx, sy = S.sy;
for (var i = 0; i < n; i++) { var dx = sx[i] - px, dy = sy[i] - py, d = dx * dx + dy * dy; if (d < bd2) { bd2 = d; best = i; } }
if (best < 0) return false;
var sub = S.pSub[best];
if (S.D < 2) { flyTo(sub); }
else { setTarget(sub, true); S.Dgoal = Math.max(S.Dgoal, Math.min(DMAX, S.D + 1.5)); ping(5, 0.03); caption(nameOf(sub).toUpperCase()); }
return true;
}
function open(host) {
if (S) close();
if (!SUB || !window.KuiperLaw) { host.textContent = 'descent.js: data or KuiperLaw missing'; return; }
S = { host: host, listeners: [], allBtns: [], D: 0, Dgoal: 0, speed: 2.4, hold: 0, T: -1, corrA: 0, corrX: 0, corrY: 0, cam: { x: 0, y: 0, z: 0, ws: 1 },
view: 'map', viewTouched: false, mapState: 'none', mapVis: false, mapA: -1, camKey: '', subs: true, grid: false, spiderOn: false, hops: 1,
scan: true, sw: Math.PI / 2, muted: false, stage: -1, roT: 0, roS: '', mIdx: new Int32Array(200), mN: 0, mTotal: 0, q: '',
ft: new Float32Array(120), fi: 0, fiv: new Float32Array(240), fj: 0, lite: false, cardOn: false, cardDirty: false, cardOpen: false, mapShownC: 0, pointers: {} };
S.SPACE = window.KuiperLaw.constants.SPACE;
host.style.position = host.style.position || 'fixed'; host.style.overflow = 'hidden'; host.style.background = '#000';
S.mapEl = el('div', 'position:absolute;inset:0;visibility:hidden;opacity:0;pointer-events:none;background:#000', null, host);
var cv = el('canvas', 'position:absolute;left:0;top:0;touch-action:none;display:block', null, host);
cv.setAttribute('aria-label', 'See through the universe to one substation');
S.cv = cv; S.ctx = cv.getContext('2d');
var ui = el('div', 'position:absolute;inset:0;pointer-events:none;font:24px ' + FONT + ';color:#fff', null, host); S.ui = ui; ui.classList.add('st-plain');
var pad = 'env(safe-area-inset-top)';
S.cap = el('div', 'position:absolute;left:16px;top:calc(16px + ' + pad + ');font:bold 26px/1.15 ' + FONT + ';color:#fff;max-height:62px;overflow:hidden', '', ui);
S.ro = el('div', 'position:absolute;left:16px;font:24px ' + FONT + ';color:rgba(0,255,255,0.7);white-space:nowrap', '', ui);
S.att = el('div', 'position:absolute;font:16px/1.3 ' + FONT + ';color:rgba(160,210,255,0.85);display:none;text-shadow:0 0 3px #000;white-space:pre-line', '', ui);
S.card = el('div', 'position:absolute;background:rgba(0,0,0,0.8);border:1px solid rgba(255,176,0,0.55);border-radius:10px;padding:8px 12px;font:24px/1.3 ' + FONT + ';display:none;pointer-events:auto;overflow:auto;box-sizing:border-box', '', ui);
S.netNote = el('div', '', '', ui); S.netNote.setAttribute('role', 'status');
S.card.addEventListener('pointerdown', function (e) { e.stopPropagation(); });
// the search box: GridAtlas position and style (dark box, cyan outline GO)
S.search = el('div', 'position:absolute;display:flex;gap:8px;pointer-events:auto', null, ui);
S.input = el('input', 'flex:1;min-width:0;box-sizing:border-box;background:rgba(0,0,0,0.85);color:#fff;border:1px solid rgba(0,255,255,0.35);border-radius:6px;padding:0 12px;font:24px ' + FONT + ';outline:none', null, S.search);
S.input.type = 'text'; S.input.placeholder = 'Substation name'; S.input.maxLength = 80; S.input.autocomplete = 'off'; S.input.spellcheck = false;
S.input.setAttribute('aria-label', 'Substation name');
S.input.addEventListener('input', function () { audio(); doSearch(); });
S.input.addEventListener('keydown', function (e) {
if (e.key === 'Enter') { e.preventDefault(); goSearch(); }
else if (e.key === 'Escape') { e.preventDefault(); S.input.blur(); }
e.stopPropagation();
});
S.input.addEventListener('focus', function () { S.input.style.borderColor = 'rgba(0,255,255,0.8)'; });
S.input.addEventListener('blur', function () { S.input.style.borderColor = 'rgba(0,255,255,0.35)'; });
S.goB = btn('GO', S.search, goSearch, 'go to this substation');
S.goB.style.cssText += ';border-color:rgba(0,255,255,0.8);opacity:0.85';
S.note = el('div', 'position:absolute;font:24px/1.2 ' + FONT + ';color:rgba(255,176,0,0.9);text-shadow:0 0 4px #000', '', ui);
// top right: X and mute
S.xbtn = btn('X', ui, back, 'back');
S.xbtn.style.cssText += ';position:absolute;right:calc(8px + env(safe-area-inset-right));top:calc(8px + ' + pad + ');font-size:34px;padding:0;opacity:0.7';
S.mute = btn('♪', ui, function () { S.muted = !S.muted; S.mute.textContent = S.muted ? '♪ OFF' : '♪'; if (S.og) S.og.gain.value = 0; }, 'mute');
S.mute.style.position = 'absolute';
// bottom-left: GRID SUBS SPIDER, lit when on (GridAtlas mobile chips)
S.grpBL = el('div', 'position:absolute;display:flex;gap:6px;pointer-events:none', null, ui);
S.gridB = btn('GRID', S.grpBL, function () { S.grid = !S.grid; lit(S.gridB, S.grid); if (S.map && S.mapState === 'ready') GA_LINES.forEach(function (L) { try { S.map.setLayoutProperty('ga' + L[0], 'visibility', S.grid ? 'visible' : 'none'); } catch (e) {} }); caption(S.grid ? '400 kV AND 132 kV LINES, OPENSTREETMAP' : 'LINES OFF'); S.attDirty = true; }, 'grid lines');
S.subsB = btn('SUBS', S.grpBL, function () { S.subs = !S.subs; lit(S.subsB, S.subs); caption(S.subs ? 'EVERY SUBSTATION' : 'SUBSTATIONS OFF'); }, 'substations');
S.spB = btn('SPIDER', S.grpBL, function () { S.spiderOn = !S.spiderOn; lit(S.spB, S.spiderOn); S.spider = null; S.spiderT0 = performance.now(); if (!S.spiderOn) caption('SPIDER OFF'); else if (S.T < 0 || S.D < 2.4) caption('CHOOSE A SUBSTATION FIRST'); S.cardDirty = true; }, 'spider arrows');
lit(S.subsB, true);
// view switch
S.grpView = el('div', 'position:absolute;display:flex;gap:6px;pointer-events:none', null, ui);
S.viewBtns = [['kuiper', 'KUIPER'], ['map', 'MAP'], ['sat', 'SAT'], ['3d', '3D']].map(function (v) {
var b = btn(v[1], S.grpView, function () { setView(v[0], true); }, v[1].toLowerCase() + ' view'); b.dataset.v = v[0]; return b;
});
S.satB = S.viewBtns[2]; lit(S.viewBtns[1], true); S.b3d = S.viewBtns[3];
// DESCEND / ASCEND: hold to keep moving, tap for one step
S.grpUD = el('div', 'position:absolute;display:flex;gap:6px;pointer-events:none', null, ui);
function holdBtn(label, dir, title) {
var b = btn(label, S.grpUD, null, title), t0 = 0;
b.addEventListener('pointerdown', function (e) { e.stopPropagation(); audio(); S.flight = null; S.hold = dir; t0 = performance.now(); try { b.setPointerCapture(e.pointerId); } catch (x) {} });
var stop = function () { if (S && S.hold === dir) { S.hold = 0; if (performance.now() - t0 < 220) S.Dgoal = clamp(S.Dgoal + dir * 0.6, 0, DMAX); } };
b.addEventListener('pointerup', stop); b.addEventListener('pointercancel', stop); b.addEventListener('lostpointercapture', stop);
b.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); S.Dgoal = clamp(S.Dgoal + dir * 0.6, 0, DMAX); } });
return b;
}
S.upB = holdBtn('▲', -1, 'ascend'); S.dnB = holdBtn('▼', 1, 'descend');
S.upB.dataset.cmd = 'ascend'; S.dnB.dataset.cmd = 'descend';
// particles: the DRAW THE GRID keys; particle j < 5800 lands on substation j, the rest gather around substations
// Desktop: all 20,000 DRAW THE GRID keys, particle p carries key index p. Phone: the first 5,800 the same, then every
// second key of the rest (12,900 stars). Particle p goes to substation p mod 5,800, so substation j always gets the star
// with key index j: its STAR KEY is grid.js keyOf(j) on every device.
var L = window.KuiperLaw, phoneNow = Math.min(host.clientWidth || innerWidth, host.clientHeight || innerHeight) < 600;
var n = phoneNow ? NSUB + Math.ceil((NRULE - NSUB) / 2) : NRULE; S.NP = n;
S.kx = new Float32Array(n); S.ky = new Float32Array(n); S.delay = new Float32Array(n); S.pSub = new Int32Array(n);
S.ox = new Float32Array(n); S.oy = new Float32Array(n); S.sx = new Float32Array(n); S.sy = new Float32Array(n);
S.subKey = new Float64Array(NSUB);
S.starCv = document.createElement('canvas'); S.starCtx = S.starCv.getContext('2d'); S.starKey = ''; S.layoutN = 0;
S.bCnt = new Int32Array(360); S.bStart = new Int32Array(361); S.bItem = new Int32Array(n); S.bOf = new Int16Array(n); S.bucketsOK = false;
S.phoneStars = phoneNow; cutStars(S.SPACE);
// canvas input: tap picks, wheel and pinch descend, a drag grabs the sweep arm
on(cv, 'pointerdown', function (e) {
audio(); S.pointers[e.pointerId] = { x: e.clientX, y: e.clientY, x0: e.clientX, y0: e.clientY };
var ids = Object.keys(S.pointers);
if (ids.length === 2) { var a = S.pointers[ids[0]], b = S.pointers[ids[1]]; S.pinch = Math.hypot(a.x - b.x, a.y - b.y) || 1; S.flight = null; }
try { cv.setPointerCapture(e.pointerId); } catch (x) {}
});
on(cv, 'pointermove', function (e) {
var pp = S.pointers[e.pointerId]; if (!pp) return; pp.x = e.clientX; pp.y = e.clientY;
var ids = Object.keys(S.pointers);
if (ids.length === 2 && S.pinch) {
var a = S.pointers[ids[0]], b = S.pointers[ids[1]], d = Math.hypot(a.x - b.x, a.y - b.y) || 1;
S.Dgoal = clamp(S.Dgoal + Math.log(d / S.pinch) / Math.LN2 * 0.9, 0, DMAX); S.pinch = d;
} else if (ids.length === 1 && Math.hypot(pp.x - pp.x0, pp.y - pp.y0) > 12) {
var r = cv.getBoundingClientRect(); S.grab = true; S.sw = -Math.atan2(pp.y - r.top - S.cy, pp.x - r.left - S.cx);
}
});
function up(e) {
var pp = S.pointers[e.pointerId]; delete S.pointers[e.pointerId];
if (Object.keys(S.pointers).length < 2) S.pinch = 0;
if (!pp) return;
if (!S.grab && Math.hypot(pp.x - pp.x0, pp.y - pp.y0) < 12 && e.type === 'pointerup') {
var r = cv.getBoundingClientRect(); pick(e.clientX - r.left, e.clientY - r.top);
}
if (!Object.keys(S.pointers).length) { if (S.grab) { S.sw = (S.sw + 2 * Math.PI) % (2 * Math.PI); } S.grab = false; }
}
on(cv, 'pointerup', up); on(cv, 'pointercancel', up);
on(cv, 'wheel', function (e) {
e.preventDefault(); audio(); S.flight = null;
var dy = +e.deltaY || 0; if (e.deltaMode === 1) dy *= 30; else if (e.deltaMode === 2) dy *= 600;
if (!isFinite(dy)) return;
S.Dgoal = clamp(S.Dgoal + clamp(dy * 0.0025, -0.8, 0.8), 0, DMAX);
}, { passive: false });
on(window, 'keydown', function (e) {
var tg = e.target && e.target.tagName;
if (e.key === 'Escape') {
if (tg === 'INPUT' || tg === 'TEXTAREA') { e.target.blur(); return; }
back(); return;
}
if (tg === 'INPUT' || tg === 'TEXTAREA') return;
var k = e.key;
if (S.in3d) { if (k === '1') setView('kuiper', true); else if (k === '2') setView('map', true); else if (k === '3') setView('sat', true); return; }
if (k === 'ArrowDown' || k === 'PageDown' || k === '+' || k === '=') { e.preventDefault(); audio(); S.flight = null; S.Dgoal = clamp(S.Dgoal + 0.5, 0, DMAX); }
else if (k === 'ArrowUp' || k === 'PageUp' || k === '-' || k === '_') { e.preventDefault(); audio(); S.flight = null; S.Dgoal = clamp(S.Dgoal - 0.5, 0, DMAX); }
else if (k === 'Home') { S.flight = null; S.Dgoal = 0; }
else if (k === 'End') { S.flight = null; S.Dgoal = DMAX; }
else if (k === '1') setView('kuiper', true); else if (k === '2') setView('map', true); else if (k === '3') setView('sat', true); else if (k === '4') setView('3d', true);
else if (k === '/' ) { e.preventDefault(); S.input.focus(); }
});
on(window, 'resize', function () { if (S) layout(); });
on(window, 'orientationchange', function () { setTimeout(function () { if (S) layout(); }, 200); });
on(document, 'visibilitychange', function () {
if (!S) return;
if (document.hidden) { cancelAnimationFrame(S.raf); S.raf = 0; if (S.og) S.og.gain.value = 0; }
else if (!S.raf) { S.last = 0; S.raf = requestAnimationFrame(frame); }
});
decode();
layout();
caption('SEE THROUGH');
S.stage = 0;
S.raf = requestAnimationFrame(frame);
// fetch the map library while the player is still among the stars, so its first parse does not stall the fall
S.preT = setTimeout(function () { if (S && wantMap()) loadMap(); }, 1500);
window.__descent = {
state: function () { return S && { D: S.D, Dgoal: S.Dgoal, T: S.T, name: S.T >= 0 ? nameOf(S.T) : '', view: S.view, mapState: S.mapState, mapVis: S.mapVis,
tileOK: S.tileOK || 0, tileErr: S.tileErr || 0, z: S.cam.z, W: S.W, H: S.H, Rpx: S.Rpx, NP: S.NP, cap: S.cap.textContent, note: S.note.textContent,
mN: S.mN, mTotal: S.mTotal, card: S.cardOn ? S.card.textContent : '', att: S.att.textContent, flight: S.flight && S.flight.phase,
spider: S.spider && { kind: S.spider.kind, n: S.spider.arrows.length, labels: S.spider.arrows.map(function (a) { return a.name + ' ' + a.label; }) }, lite: S.lite, grid: S.grid, subs: S.subs, in3d: !!S.in3d,
space: S.SPACE, spaceSource: S.spaceSource, link: linkText() }; },
view: function (v) { setView(v, true); },
frameTimes: function () { return Array.prototype.slice.call(S.ft); },
frameIntervals: function () { return Array.prototype.slice.call(S.fiv, 0, Math.min(S.fj, S.fiv.length)); },
setD: function (d) { S.flight = null; S.Dgoal = clamp(+d || 0, 0, DMAX); },
jumpD: function (d) { S.flight = null; S.D = S.Dgoal = clamp(+d || 0, 0, DMAX); },
target: function (i) { setTarget(i, false); },
fly: function (i) { flyTo(i); },
find: function (name) { var q = String(name).toLowerCase(); for (var i = 0; i < D0.n; i++) if (D0.low[i] === q) return i; return -1; },
sub: function (i) { return { name: D0.names[i], lat: D0.lat[i], lon: D0.lon[i], volt: voltText(i), op: opText(i) }; },
screenOf: function (i) { return [S.sx[i], S.sy[i]]; },
mapPointOf: function (i) { if (!S.map) return null; var p = S.map.project([D0.lon[i], D0.lat[i]]); return [p.x, p.y]; },
mapReady: function () { return !!(S.map && S.mapState === 'ready' && S.map.loaded() && S.map.areTilesLoaded()); },
link: function () { return linkText(); },
subKey: function (i) { return keyOfSub(i); },
ring: function () { return S.ring ? { x: S.cx + S.ring.x * S.Rpx / S.Rw, y: S.cy - S.ring.y * S.Rpx / S.Rw, key: S.ring.key } : null; },
sky: function () { return { space: S.SPACE, spaceSource: S.spaceSource, wafer: S.waferSpace || null }; },
repoLit: function () { return S.repoLit ? S.repoLit.length : (S.repoN === 0 ? 0 : -1); }
};
S.linkWait = 2; // the link is read once the names are in and the sky is settled
ensureGridData(function () {
if (!S) return;
var names = window.KGGridData && window.KGGridData.substations && window.KGGridData.substations.names;
if (names) for (var q = 0; q < D0.n; q++) { D0.names[q] = names[q] || ''; D0.low[q] = D0.names[q].toLowerCase(); }
else caption('grid-data.js did not load: names and lines are missing');
if (--S.linkWait === 0) readLink();
});
on(window, 'hashchange', function () { if (S && S.linkWait <= 0 && location.hash !== linkText()) readLink(); });
readSky(function () { if (S && --S.linkWait === 0) readLink(); });
}
function close() {
if (!S) return;
if (S.in3d && window.SeeThrough3D) { try { window.SeeThrough3D.exit(); } catch (e) {} }
cancelAnimationFrame(S.raf); clearTimeout(S.capT); clearTimeout(S.libTimer); clearTimeout(S.preT);
S.listeners.forEach(function (l) { l[0].removeEventListener(l[1], l[2], l[3]); });
if (S.map) { try { S.map.remove(); } catch (e) {} }
if (S.ac) { try { S.osc.stop(); S.ac.close(); } catch (e) {} }
var h = S.host; S = null;
while (h.firstChild) h.removeChild(h.firstChild);
window.__descent = null;
}
var M = { back: back, id: 'descent', label: 'SEE THROUGH', sentence: 'See through the universe to one substation', open: open, close: close };
(window.KGModules = window.KGModules || []).push(M);
})();Kuiper Law
A JavaScript module in the see through folder of Kuiper Belt that places many (`placeMany`) and converts to screen (`toScreen`).
renderkuiper-belt / see-through/202611020012/kuiper-law.js · lines 1–123 of 123 · version 2026-11-02 00:12 · Entry point · pattern placeMany (shared by 2 files)
- What it does
- It draws its content. Defines 6 functions or classes, including keyPlace, place, placeMany, shader, toScreen. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). README: "kuiper-law.js holds the frozen value (63,340,120,796) used when that file cannot be read."
- Downstream impact
- Used directly by 1 file: Kuiper Belt — See Through Page (kuiper-belt, https://ventusltd.github.io/kuiper-belt/see-through/202610050513/).
- What it achieves
- It places many (`placeMany`) and is built from the key place helper (`keyPlace`) and the place step (`place`). `kuiper-law.js` THE ONE LAW OF THE REAL KUIPER, lifted VERBATIM from the live page.
- Why it matters
- Loaded by the See Through page at https://ventusltd.github.io/kuiper-belt/see-through/202610050513/.
- Application
- kuiper-belt · see-through/202611020012 · JavaScript module
- Uses
- Kuiper Belt — Index Page (estate URL)
- Used by
- loaded by Kuiper Belt — See Through Page (script src)
- Produces
- keyPlace, place, placeMany, shader, toScreen, homeZoom
- Defines here
- keyPlace, place, placeMany, shader, toScreen, homeZoom
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- kuiper-belt@26fba12ab1b5bab8e71934ab86c58273e5f32682 see-through/202611020012/kuiper-law.js:1-123 · blob 180da0cc157440e01b5f5a14fb22b71e4faea910 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: agent_infra · users: ai_agent · canonical: duplicate_candidate
// kuiper-law.js THE ONE LAW OF THE REAL KUIPER, lifted VERBATIM from the live page.
// Source: github.com/Ventusltd/kuiper-belt index.html @ commit 7a65dd315b0c60b1baf9a7090206c900b2cfd0a1
// (2026-10-04 16:08 +0100, "docs: add What is the Kuiper page"), live at https://ventusltd.github.io/kuiper-belt/
// Every screen of LEARN THE KUIPER GAME that places a real-wafer particle must go through window.KuiperLaw.
// Nothing in here is invented: every formula below is quoted with the live line number it came from.
//
// index.html:79 // key k -> r = sqrt(k), theta = 2 pi frac(k G / 2^32), G = 2654435769
// index.html:92 const G32 = 2654435769, TW = 4096;
// index.html:250 function keyPlace(k){ const m = Math.imul((k % 4294967296) >>> 0, G32) >>> 0, th = 2*Math.PI*m/4294967296, r = Math.sqrt(k + 0.5);
// index.html:251 return [r*Math.cos(th), r*Math.sin(th)]; }
// index.html:143 float d = float(gl_VertexID);
// index.html:144 float r = u_R0 + (d + 0.5) / (u_R0 + sqrt(u_R0*u_R0 + d + 0.5) + 1e-9); // sqrt(k0+d+.5), kept precise
// index.html:145 uint m = (u_k0lo + uint(gl_VertexID)) * ${G32}u;
// index.html:146 float A = 6.283185307179586 * float(m >> 16) / 65536.0, B = 6.283185307179586 * float(m & 0xFFFFu) / 4294967296.0;
// index.html:147 vec2 cs = vec2(cos(A)*cos(B) - sin(A)*sin(B), sin(A)*cos(B) + cos(A)*sin(B));
// index.html:148 gl_Position = vec4((r*cs - u_center) * u_zoom / (0.5*u_res), 0.0, 1.0);
// index.html:333 for (let off = s0; off < s1; off += 4000000) { // bounded calls; the driver watchdog is real
// index.html:334 gl.uniform1ui(U(PK,'u_k0lo'), (off % 4294967296) >>> 0); gl.uniform1f(U(PK,'u_R0'), Math.sqrt(off));
// index.html:335 gl.drawArrays(gl.POINTS, 0, Math.min(4000000, s1 - off)); } }
// index.html:357 { const x0 = (0 - cx)*zoom + ov.width/2, y0 = ov.height/2 + cy*zoom, ... (the 2D overlay: world y is UP on screen)
//
// WHAT THE LAW SAYS, in words that match the code exactly:
// keys start at 0. m = (key * 2654435769) mod 2^32, an unsigned 32-bit integer product (Math.imul, wrapping).
// turns = m / 2^32 the angle as a fraction of one full turn, in [0, 1)
// theta = 2 pi turns radians, anticlockwise from +x, with world y UP on screen (WebGL clip space, :148; overlay :357)
// r = sqrt(key + 0.5) the radius; NOT sqrt(key). The half is in the live code at :250 and :144.
// Successive keys turn by G32/2^32 = 0.6180339887 of a turn = 222.4922 degrees anticlockwise on screen, which is the
// same point as 137.5078 degrees CLOCKWISE. The Excel "137.5 anticlockwise" spiral is the MIRROR IMAGE of the Kuiper.
// Keys beyond 2^32 wrap: key % 4294967296 first (:250), and the shader gets the low 32 bits of the batch offset (:334).
(function (root) {
'use strict';
// index.html:92 const G32 = 2654435769, TW = 4096;
const G32 = 2654435769, TW = 4096;
const TWO32 = 4294967296;
// the whole wafer as of this commit: sum of every gap_before and lines in cosmos/wafer.tsv (index.html:180 N = issued; SPACE = k;)
// RE-LIFTED (NL-010 step 5.6): the law above is unchanged at kuiper-belt@96736f5 (index.html:92, :250-251); only the sky
// grew. SPACE is the address_space of kuiper-belt@96736f5 cosmos/wafer-meta.json:4, re-summed from cosmos/wafer.tsv
// (lines + gap_before over 13,344 rows = 63,340,120,796). Was 59,637,070,538 at 7a65dd3. descent.js also reads
// ../../cosmos/wafer-meta.json at run time and uses it while nothing is chosen (this value when it cannot).
const SPACE = 63340120796;
// index.html:250-251, VERBATIM. This is the electron. Do not edit it; edit the live page and re-lift.
function keyPlace(k){ const m = Math.imul((k % 4294967296) >>> 0, G32) >>> 0, th = 2*Math.PI*m/4294967296, r = Math.sqrt(k + 0.5);
return [r*Math.cos(th), r*Math.sin(th)]; }
// The same law, opened up so the game can show each part: m, turns, degrees, r, x, y.
// Every expression here is the one in keyPlace at :250, nothing added.
function place(key){
const k = +key;
const m = Math.imul((k % 4294967296) >>> 0, G32) >>> 0; // :250
const turns = m / 4294967296; // :250 th = 2*Math.PI*m/4294967296
const th = 2*Math.PI*m/4294967296; // :250
const r = Math.sqrt(k + 0.5); // :250
return { key: k, m: m, turns: turns, deg: turns * 360, theta: th, r: r, x: r*Math.cos(th), y: r*Math.sin(th) };
}
// n keys from k0, x,y interleaved, exactly as the live batch does it (:333-335): u_k0lo is the low 32 bits of the
// batch offset and the shader adds gl_VertexID in uint32. Written here with keyPlace so the result is identical to :250.
function placeMany(k0, n, out){
out = out || new Float64Array(2*n);
for (let d = 0; d < n; d++) { const p = keyPlace(k0 + d); out[2*d] = p[0]; out[2*d+1] = p[1]; }
return out;
}
// The vertex shader at :143-148 reproduced in float32, as the GPU computes it. The live view itself has these float32
// differences from keyPlace; they are reported separately in kuiper-law.receipt.json and are not photons.
const f = Math.fround;
function shader(k0, d){
// :334 gl.uniform1ui(U(PK,'u_k0lo'), (off % 4294967296) >>> 0); gl.uniform1f(U(PK,'u_R0'), Math.sqrt(off));
const u_k0lo = (k0 % 4294967296) >>> 0, u_R0 = f(Math.sqrt(k0));
// :143 float d = float(gl_VertexID);
const fd = f(d);
// :144 float r = u_R0 + (d + 0.5) / (u_R0 + sqrt(u_R0*u_R0 + d + 0.5) + 1e-9);
const r = f(u_R0 + f(f(fd + 0.5) / f(f(u_R0 + f(Math.sqrt(f(f(f(u_R0*u_R0) + fd) + 0.5)))) + f(1e-9))));
// :145 uint m = (u_k0lo + uint(gl_VertexID)) * ${G32}u;
const m = Math.imul((u_k0lo + d) >>> 0, G32) >>> 0;
// :146 float A = 6.283185307179586 * float(m >> 16) / 65536.0, B = 6.283185307179586 * float(m & 0xFFFFu) / 4294967296.0;
const A = f(f(f(6.283185307179586) * f(m >>> 16)) / 65536.0), B = f(f(f(6.283185307179586) * f(m & 0xFFFF)) / 4294967296.0);
// :147 vec2 cs = vec2(cos(A)*cos(B) - sin(A)*sin(B), sin(A)*cos(B) + cos(A)*sin(B));
const cA = f(Math.cos(A)), sA = f(Math.sin(A)), cB = f(Math.cos(B)), sB = f(Math.sin(B));
const cs = [f(f(cA*cB) - f(sA*sB)), f(f(sA*cB) + f(cA*sB))];
return { key: k0 + d, m: m, turns: m / TWO32, r: r, x: f(r*cs[0]), y: f(r*cs[1]) };
}
// World to screen, as the live page does it. :148 puts world y UP (WebGL clip space); the 2D overlay at :357 agrees
// (y0 = ov.height/2 + cy*zoom). A 2D canvas is y-down, so the game must FLIP y when it draws KuiperLaw points.
function toScreen(x, y, cam, W, H){
return [ W/2 + (x - cam.cx) * cam.zoom, H/2 - (y - cam.cy) * cam.zoom ];
}
// index.html:244-248, how the live home camera frames the whole wafer: radius = 80% of half the clear box.
function homeZoom(boxW, boxH, space){ return Math.min(boxW, boxH) / 2 * 0.80 / Math.sqrt(space == null ? SPACE : space); }
const constants = {
G32: G32, TW: TW, TWO32: TWO32, SPACE: SPACE, KEYS_FROM: 0, RADIUS_OFFSET: 0.5,
TURN_PER_KEY: G32 / TWO32, // 0.6180339887 of a turn per key
DEG_PER_KEY_ANTICLOCKWISE: 360 * G32 / TWO32, // 222.4922359 degrees anticlockwise, y up
DEG_PER_KEY_CLOCKWISE: 360 - 360 * G32 / TWO32, // 137.5077641 degrees clockwise, the same point
Y_UP_ON_SCREEN: true, BATCH: 4000000, MAX_CALLS: 3000, POINTS_FROM: 1.0
};
// TEACHING VARIANT, clearly NOT THE REAL KUIPER. The spreadsheet spiral: theta = key x 137.507764 degrees anticlockwise,
// r = sqrt(key) (no half). Its angle runs the OTHER WAY round and its radius is off by sqrt(k+0.5)-sqrt(k). Show it only
// beside the real one, labelled. It exists so a learner can see why the Kuiper is not it.
const teach = {
excel: function (key) {
const k = +key, deg = (k * 137.507764) % 360, th = deg * Math.PI / 180, r = Math.sqrt(k);
return { key: k, deg: deg, turns: deg / 360, theta: th, r: r, x: r*Math.cos(th), y: r*Math.sin(th),
label: 'NOT THE REAL KUIPER: Excel spiral, 137.507764 deg per key anticlockwise, r = sqrt(key)' };
},
label: 'NOT THE REAL KUIPER'
};
const KuiperLaw = {
place: place, placeMany: placeMany, keyPlace: keyPlace, shader: shader, toScreen: toScreen, homeZoom: homeZoom,
constants: constants, teach: teach,
source: 'kuiper-belt@7a65dd315b0c60b1baf9a7090206c900b2cfd0a1 index.html:92,143-148,250-251,333-335,357; SPACE re-lifted at kuiper-belt@96736f55c2137defcf02c898f8f2b0d04374d74b cosmos/wafer-meta.json:4',
live: 'https://ventusltd.github.io/kuiper-belt/'
};
Object.freeze(constants); Object.freeze(KuiperLaw);
root.KuiperLaw = KuiperLaw;
if (typeof module !== 'undefined' && module.exports) module.exports = KuiperLaw;
})(typeof window !== 'undefined' ? window : globalThis);Kuiper Belt — See Through Page
A web page. Published at https://ventusltd.github.io/kuiper-belt/see-through/.
renderkuiper-belt / see-through/index.html · lines 1–14 of 14 · Entry point
- What it does
- It draws its content. Side effects: changes the web page (DOM); uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). README: "Download the newest dated folder and open `index.html` in a web browser."
- Inputs & outputs
- Out: browser storage (setItem); web page.
- Downstream impact
- Used directly by 11 files: SatNav — Scope Page (satnav, https://ventusltd.github.io/satnav/scope/); Apps Registry (kuiper-belt); Repokuiper Galaxy (cosmic); Test Agentdocs (cosmic); and 7 more. Reached from 12 other entry points, including Build Homepage Release Candidate Workflow (globalgrid2050-homepage); PR Checks Workflow (globalgrid2050-homepage); Pages Workflow (globalgrid2050-homepage). It is itself an entry point, published at https://ventusltd.github.io/kuiper-belt/see-through/.
- What it achieves
- The README says: Download the newest dated folder and open `index.html` in a web browser.
- Why it matters
- Loaded by the Scope page in SatNav at https://ventusltd.github.io/satnav/scope/ and 2 other pages. Also imported by Apps Registry, Repokuiper Galaxy and Seethrough Index, from Cosmic. Checked by 5 tests, including Test Agentdocs.
- Application
- kuiper-belt · see-through · page
- Uses
- none found
- Used by
- linked from SatNav — Scope Page (link), named by URL in Apps Registry (estate URL), named by URL in Repokuiper Galaxy (estate URL), named by URL in Test Agentdocs (estate URL), named by URL in Seethrough Index (estate URL), named by URL in Test Seethrough (estate URL), linked from GlobalGrid2050 — Kuiper Editions Page (link), linked from Kuiper Belt — Diary Page (link), and 3 more, mentioned in Seethrough (comment link)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- kuiper-belt@26fba12ab1b5bab8e71934ab86c58273e5f32682 see-through/index.html:1-14 · blob 3017bdeb497792daec8909620cbe859191ec04fc · GitHub at these lines
- State
- achieves: readme · context: readme_derived · stage: output · effects: dom, storage · domain stage: agent_infra · users: ai_agent · canonical: unknown
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>See Through</title>
<meta http-equiv="refresh" content="0; url=202611020012/">
<style>html,body{margin:0;height:100%;background:#000;color:#fff;font:400 24px/1.4 "Segoe UI",Arial,sans-serif}a{color:#fff}main{padding:32px 20px}</style>
</head>
<body>
<main>Opening See Through. <a href="202611020012/">Tap here if it does not open.</a></main>
<script>try { sessionStorage.setItem('seeThroughFrom', document.referrer); } catch (e) {} location.replace('202611020012/' + location.search + location.hash);</script>
</body>
</html>