Skip to content

Commit 1e129ac

Browse files
captkernelclaude
andcommitted
Bundle My Sky star datasets into the repo (CDN fallback)
Serve d3-celestial stars.6.json (5044 stars) + constellations.lines.json (89 lines) from same-origin /sky/ instead of jsDelivr at runtime — removes the third-party dependency that ad-blockers / locked-down networks break. loadSkyData() tries the bundle first and falls back to the CDN if absent. Add .nojekyll so Pages serves the JSON verbatim. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent dde314b commit 1e129ac

4 files changed

Lines changed: 6 additions & 2 deletions

File tree

.nojekyll

Whitespace-only changes.

index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,10 @@
618618
if(ed<R&&ed>0.01){var f=1-ed/R,pu=f*f*ks;d.x=d.ox+(ex/ed)*pu;d.y=d.oy+(ey/ed)*pu;}else{d.x=d.ox;d.y=d.oy;}}}
619619
/* fetch the real star + constellation datasets (cached after first load) */
620620
function loadSkyData(cb){if(SKYDATA.stars&&SKYDATA.lines){cb(true);return;}
621-
var base='https://cdn.jsdelivr.net/gh/ofrohn/d3-celestial@master/data/';
622-
Promise.all([fetch(base+'stars.6.json').then(function(r){return r.json();}),fetch(base+'constellations.lines.json').then(function(r){return r.json();})])
621+
var cdn='https://cdn.jsdelivr.net/gh/ofrohn/d3-celestial@master/data/'; /* fallback only */
622+
function grab(name){return fetch('sky/'+name).then(function(r){if(!r.ok)throw 0;return r.json();}) /* bundled (same-origin) first */
623+
.catch(function(){return fetch(cdn+name).then(function(r){return r.json();});});} /* CDN if the bundle is missing */
624+
Promise.all([grab('stars.6.json'),grab('constellations.lines.json')])
623625
.then(function(res){SKYDATA.stars=res[0];SKYDATA.lines=res[1];cb(true);}).catch(function(){cb(false);});}
624626
/* ---- Random mode: a 3D warp starfield (Lenis-driven dive toward the cursor) ---- */
625627
function newWarpStar(z){return {x3:Math.random()*2-1,y3:Math.random()*2-1,z3:z,br:(Math.random()<0.06?0.85+Math.random()*0.15:0.18+Math.random()*0.5),ph:Math.random()*6.283,tw:0.4+Math.random()*1.4};}

0 commit comments

Comments
 (0)