Spaces:
Running
Running
File size: 9,147 Bytes
057a205 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dome test: standing on the field</title>
<style>
html, body { margin: 0; height: 100%; background: #061522; color: #d9d5c5;
font: 13px ui-monospace, Menlo, Consolas, monospace; overflow: hidden; }
#dome { position: fixed; inset: 0; cursor: grab; outline: none; }
#dome.dragging { cursor: grabbing; }
#dome:focus-visible { box-shadow: inset 0 0 0 2px #66b9ef; }
.dome-unsupported { position: absolute; inset: 0; display: grid; place-items: center; color: #9fd3f5; font-size: 16px; }
#cross { position: fixed; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; pointer-events: none;
border: 1px solid rgba(102, 185, 239, 0.55); border-radius: 50%; }
#info { position: fixed; left: 12px; bottom: 12px; padding: 8px 10px; background: rgba(6, 21, 34, 0.75);
border: 1px solid #17374f; border-radius: 4px; line-height: 1.55; pointer-events: none; max-width: 92vw; }
#info b { color: #66b9ef; font-weight: 600; }
#layers { position: fixed; top: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 80vw; }
#layers button, #toggles button { font: inherit; color: #d9d5c5; background: rgba(6, 21, 34, 0.75); border: 1px solid #17374f;
border-radius: 4px; padding: 6px 10px; cursor: pointer; }
#layers button[aria-pressed="true"], #toggles button[aria-pressed="true"] { border-color: #66b9ef; color: #9fd3f5; }
#layers button:focus-visible, #toggles button:focus-visible { outline: 2px solid #66b9ef; outline-offset: 2px; }
#toggles { position: fixed; top: 12px; left: 12px; display: flex; gap: 6px; }
#problems { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); max-width: 90vw; padding: 10px 14px; z-index: 10;
background: #3a1410; color: #ffd9d2; border: 1px solid #d94d35; border-radius: 4px; line-height: 1.5; display: none; }
</style>
</head>
<body>
<div id="dome" aria-label="Sky dome"></div>
<div id="cross"></div>
<div id="problems" role="alert"></div>
<div id="toggles" role="group" aria-label="Scene options"></div>
<div id="layers" role="group" aria-label="Sky layer"></div>
<div id="info">
<div><b>Dome test</b> – drag look · wheel/pinch zoom · arrows pan · +/− zoom · R reset</div>
<div id="center"></div>
<div id="click">Click the sky (try a red cross): coordinates appear here.</div>
<div id="obs"></div>
<div id="src"></div>
</div>
<script src="/three.min.js"></script>
<script>if (!window.THREE) document.write('<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/build/three.min.js"><\/script>');</script>
<script src="dome-coords.js"></script>
<script src="dome.js"></script>
<script src="dome-look.js"></script>
<script src="dome-layers.js"></script>
<script src="dome-landscape.js"></script>
<script src="app-state.js"></script>
<script src="dome-select.js"></script>
<script>
(function () {
var problemsEl = document.getElementById('problems');
function problem(msg) {
problemsEl.style.display = 'block';
var d = document.createElement('div'); d.textContent = msg; problemsEl.appendChild(d);
}
window.addEventListener('error', function (e) { problem('Script error: ' + e.message + ' (' + (e.filename || '').split('/').pop() + ':' + e.lineno + ')'); });
var NEEDED = [['THREE', 'three.js (needs internet)', true], ['DomeCoords', 'dome-coords.js', true], ['DomeView', 'dome.js', true],
['DomeLook', 'dome-look.js', true], ['DomeLayers', 'dome-layers.js', false], ['DomeLandscape', 'dome-landscape.js', false],
['DomeState', 'app-state.js', false], ['DomeSelect', 'dome-select.js', false]];
var fatal = false;
NEEDED.forEach(function (n) {
if (typeof window[n[0]] === 'undefined') {
problem('Missing file: ' + n[1] + ' (save it next to dome_test.html, then hard-refresh with Ctrl+Shift+R)' + (n[2] ? '' : ' [page continues without it]'));
if (n[2]) fatal = true;
}
});
if (fatal) return;
var C = DomeCoords;
var container = document.getElementById('dome');
var centerEl = document.getElementById('center');
var clickEl = document.getElementById('click');
var srcEl = document.getElementById('src');
var FIELD = { ra: 127.571, dec: -39.214 };
var OBS_LAT = -30, START_ALT = 22;
var lst = C.lstForTarget(FIELD.ra, FIELD.dec, OBS_LAT, START_ALT, 'east');
var observer = { lat: OBS_LAT, lst: lst };
document.getElementById('obs').textContent = 'simulated observer: latitude ' + Math.abs(OBS_LAT) + '\u00b0' + (OBS_LAT < 0 ? 'S' : 'N') +
', fixed moment (not your location, not live)';
var dome = new DomeView(container, { fov: 75 });
window.dome = dome;
if (!dome.supported) return;
function showCenter(c) {
centerEl.textContent = 'centre RA ' + C.formatRA(c.ra) + ' Dec ' + C.formatDec(c.dec) +
' | alt ' + c.alt.toFixed(1) + '\u00b0 az ' + c.az.toFixed(0) + '\u00b0 ' + C.compassPoint(c.az) + ' | FOV ' + c.fov.toFixed(0) + '\u00b0';
}
var layers = null;
var state = (typeof DomeState !== 'undefined') ? DomeState.create() : null;
var select = null;
function showSelection(info) {
if (info.ground) { clickEl.textContent = 'clicked ground (below the horizon: no sky coordinates)'; return; }
var s = info.selection;
if (!s) { clickEl.textContent = 'selection cleared. Click the sky (try a red cross).'; return; }
clickEl.textContent = 'selected RA ' + C.formatRA(s.ra) + ' (' + s.ra.toFixed(3) + '\u00b0) Dec ' + C.formatDec(s.dec) +
' (' + s.dec.toFixed(3) + '\u00b0)' + (s.alt !== undefined ? ' alt ' + s.alt.toFixed(1) + '\u00b0 az ' + s.az.toFixed(0) + '\u00b0' : '') +
' l ' + s.l.toFixed(2) + '\u00b0 b ' + s.b.toFixed(2) + '\u00b0 | ' + info.text + ' (Esc clears)';
}
var look = new DomeLook(dome, { observer: observer, startRa: FIELD.ra, startDec: FIELD.dec, startFov: 75, onChange: showCenter });
window.look = look;
showCenter(look.getCenter());
container.focus();
if (typeof DomeSelect !== 'undefined') {
select = new DomeSelect(dome, { state: state, onChange: showSelection,
getLayer: function () { return layers && layers.current ? layers.current.id : null; } });
select.bindLook(look);
window.select = select;
select.loadOutline('sky_layers/field_polys.json').then(function (ok) {
if (!ok) problem('Field outline not loaded (sky_layers/field_polys.json missing); everything else still works.');
});
}
var land = null;
try { if (typeof DomeLandscape !== 'undefined') { land = new DomeLandscape(dome, {}); window.land = land; } }
catch (err) { problem('Landscape failed: ' + err.message); }
var toggles = document.getElementById('toggles');
function toggle(label, on, fn) {
var b = document.createElement('button');
b.type = 'button'; b.textContent = label; b.setAttribute('aria-pressed', String(on));
b.addEventListener('click', function () { on = !on; b.setAttribute('aria-pressed', String(on)); fn(on); container.focus(); });
toggles.appendChild(b);
}
if (land) {
toggle('Landscape', true, function (on) { land.setVisible(on); });
toggle('Compass', true, function (on) { land.setLabels(on); });
}
toggle('Dec 0 ring', false, function (on) { dome.setReferenceLines(on); });
if (select) toggle('Field', true, function (on) { select.setOutlineVisible(on); });
var layersEl = document.getElementById('layers');
function showPattern(msg) {
srcEl.textContent = msg || 'texture: built-in test pattern (graticule + landmarks)';
dome.setSkyTexture(DomeView.makeGraticuleTexture(4096));
}
if (typeof DomeLayers === 'undefined' || new URLSearchParams(location.search).has('pattern')) {
showPattern();
} else {
layers = new DomeLayers(dome, {
onStatus: function (s) {
if (s.state === 'loading') srcEl.textContent = 'loading ' + s.id + ' ...';
if (s.state === 'error') srcEl.textContent = s.id + ': ' + s.message;
},
onChange: function (l) {
srcEl.textContent = 'layer: ' + l.label + ' \u00b7 ' + l.survey + (layers.credit(l) ? ' \u00b7 ' + layers.credit(l) : '');
Array.prototype.forEach.call(layersEl.children, function (b) { b.setAttribute('aria-pressed', String(b.dataset.id === l.id)); });
}
});
window.layers = layers;
layers.load().then(function (list) {
list.forEach(function (l) {
var b = document.createElement('button');
b.type = 'button'; b.dataset.id = l.id; b.setAttribute('aria-pressed', 'false');
b.textContent = l.label + ' (' + l.survey + ')';
b.addEventListener('click', function () { layers.show(l.id); container.focus(); });
layersEl.appendChild(b);
});
return layers.show(layers.byId['2mass-color'] ? '2mass-color' : list[0].id);
}).catch(function (err) {
showPattern('no sky_layers/manifest.json (' + err.message + '); showing test pattern');
});
}
})();
</script>
</body>
</html>
|