All-Sky Catalog
80,000 stars are laid on a sphere in three size classes by magnitude; color switches between magnitude grayscale and a blue-white to orange-red color index, and a slider scales point size globally.
Business context
All-sky catalogs support quick browsing of survey results and public outreach. The users are data processing staff and observation planners checking whether catalog coverage is uniform and whether bright stars concentrate near the galactic plane. Data comes from right ascension, declination and magnitude in catalogs such as Gaia or 2MASS; full catalogs reach hundreds of millions of rows, and the 80,000 sampled here still show the isotropic baseline after size binning.
Right ascension and declination are converted to Cartesian coordinates on the unit sphere and scaled to the required radius; because magnitudes span a wide range, a logarithmic or power compression is applied, otherwise faint stars collapse into one mass. Cesium's sphere is tied to the Earth ellipsoid and requires a separate celestial frame, and three.js needs custom point-cloud and camera code; PointCloudLayer with OrbitView renders a spherical point cloud as ordinary 3D data.
The most common mistake is sampling uniformly in polar angle: the sinθ area element is not cancelled and two false clumps pile up at the poles. Magnitude drives both point size and brightness, so the size of a bright point does not indicate physical size. When color switches between magnitude and color index, the same star means something different, so confirm the current definition before comparing screenshots.
How it works
Sampling takes u ∈ [0,1), sets cosθ = 1-2u, then derives the polar angle θ = acos(cosθ) and the azimuth φ = 2πv, giving [R·sinθ·cosφ, R·sinθ·sinφ, R·cosθ]; R = 60 is the catalog radius and everything is multiplied by 4 before rendering, because one common unit in OrbitView is about 1.23 px at zoom 0.3 and a 480-unit diameter fills roughly 590 px. Magnitude is generated as 2 + 8u^0.45, so about 5% fall within magnitude 4, 28% between 4 and 6.5, and the remaining 67% are fainter than 6.5; color index is uniform from -0.3 to 2.1 and mapped through a 32-step lookup table from blue-white [150,186,255] to orange-red [255,146,104].
PointCloudLayer applies one pointSize to the whole layer and cannot size points individually, so stars are split into three layers by magnitude: 6 px below 4, 3.2 px from 4 to 6.5 and 1.5 px above 6.5, one draw call each. In 'by magnitude' mode color darkens with magnitude and alpha drops from 248 to 118; the relation that smaller magnitude means brighter must appear in both the color and size channels, otherwise faint stars and small stars are confused. The slider only scales pointSize and never touches the data. The pitfall is sampling θ uniformly, which leaves the sinθ area element uncancelled and piles up two clumps at the poles; taking u uniform and then acos gives equal area.
| Setting | Effect |
|---|---|
| theta = acos(1-2u) | Turns uniform u into a polar angle with equal-area sampling |
| R=60 × FIT 4 | Scales the catalog radius by 4 to the framing at zoom 0.3 |
| pointSize 6 / 3.2 / 1.5 | Three magnitude layers, working around the single global pointSize |
| 32-step color-index LUT | Maps B-V from -0.3–2.1 to blue-white through orange-red |
Note. For uniform sampling on a sphere, make cosθ uniform first and then take acos; sampling θ uniformly piles two clumps at the poles.
Source
<!--
示例:全天星表
要点:8 万颗星按 acos 逆变换均匀铺在半径 60 的球面上,按星等分三档 PointCloudLayer,颜色可在星等与色指数之间切换
依赖:deck.gl 9.0 · jsDelivr CDN
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="robots" content="noindex,follow">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>全天星表</title>
<style>
html,body{height:100%;margin:0;background:#0d1117}
body{display:flex;flex-direction:column;overflow:hidden;
font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif;color:#e6e8ec}
.bar{position:relative;z-index:5;flex:0 0 auto;padding:8px 12px;background:#161b22;border-bottom:1px solid #252c36;
display:flex;gap:14px;align-items:center;font-size:12px;color:#8b93a1;flex-wrap:wrap}
.bar b{color:#58a6ff;font-weight:600}
.bar label{display:flex;align-items:center;gap:5px;cursor:pointer}
.bar input[type=checkbox]{accent-color:#4f9ef8}
.bar input[type=range]{width:150px;accent-color:#4f9ef8}
.bar button{font:inherit;font-size:12px;padding:3px 10px;border-radius:4px;cursor:pointer;
border:1px solid #2f3947;background:#1d242e;color:#c9d3e0}
.bar button:hover{background:#26303d}
.bar button.on{background:#2c4a7a;border-color:#4f8ad6;color:#dfe9ff}
.bar .sep{width:1px;height:18px;background:#2a313c;margin:0 4px}
#cv{flex:1 1 auto;min-height:0;width:100%;display:block}
</style>
</head>
<body>
<div class="bar">
<span>80,000 颗 · 球半径 60(显示 ×4)· 星等 2–10</span>
<span class="sep"></span>
<button id="mode" class="on">按色指数</button>
<label>点大小 <b id="ps">1.0</b>× <input id="size" type="range" min="0.5" max="2" step="0.1" value="1"></label>
</div>
<canvas id="cv"></canvas>
<script src="https://cdn.jsdelivr.net/npm/deck.gl@9.0.35/dist.min.js"></script>
<script>
(function () {
'use strict';
if (typeof deck === 'undefined') {
document.body.innerHTML =
'<div style="padding:24px;color:#ff8c74">deck.gl 加载失败,请检查能否访问 cdn.jsdelivr.net</div>';
return;
}
function rng(seed) {
var a = seed >>> 0;
return function () {
a = (a + 0x6D2B79F5) >>> 0;
var t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
var N = 80000, R = 60, FIT = 4, TAU = Math.PI * 2;
var rand = rng(1977);
var i;
var groups = [[], [], []];
for (i = 0; i < N; i++) {
// cos(theta) 在 [-1,1] 上均匀,theta = acos(...) 才能让点在球面上等面积分布
var theta = Math.acos(1 - 2 * rand());
var phi = rand() * TAU;
var st = Math.sin(theta);
var p = [
R * st * Math.cos(phi) * FIT,
R * st * Math.sin(phi) * FIT,
R * Math.cos(theta) * FIT
];
var mag = 2 + 8 * Math.pow(rand(), 0.45);
var ci = -0.3 + 2.4 * rand();
var g = mag < 4 ? 0 : (mag < 6.5 ? 1 : 2);
groups[g].push({ p: p, mag: mag, ci: ci });
}
var CI_STOPS = [
[150, 186, 255], [205, 222, 255], [240, 244, 255],
[255, 234, 190], [255, 182, 132], [255, 146, 104]
];
var LUT = [];
for (i = 0; i < 32; i++) {
var u = i / 31 * (CI_STOPS.length - 1);
var k = Math.min(CI_STOPS.length - 2, Math.floor(u));
var f = u - k;
LUT.push([
Math.round(CI_STOPS[k][0] + (CI_STOPS[k + 1][0] - CI_STOPS[k][0]) * f),
Math.round(CI_STOPS[k][1] + (CI_STOPS[k + 1][1] - CI_STOPS[k][1]) * f),
Math.round(CI_STOPS[k][2] + (CI_STOPS[k + 1][2] - CI_STOPS[k][2]) * f)
]);
}
var mode = 'ci';
var sizeScale = 1;
var BASE_SIZE = [6, 3.2, 1.5];
function ciColor(ci) {
var t = (ci + 0.3) / 2.4;
t = t < 0 ? 0 : (t > 1 ? 1 : t);
var c = LUT[(t * 31) | 0];
return [c[0], c[1], c[2], 245];
}
function magColor(mag) {
var t = (mag - 2) / 8;
t = t < 0 ? 0 : (t > 1 ? 1 : t);
return [
Math.round(255 - 130 * t),
Math.round(255 - 115 * t),
Math.round(255 - 55 * t),
Math.round(248 - 130 * t)
];
}
function buildLayers() {
var layers = [];
for (var g = 0; g < 3; g++) {
layers.push(new deck.PointCloudLayer({
id: 'sky-group-' + g,
data: groups[g],
coordinateSystem: deck.COORDINATE_SYSTEM.CARTESIAN,
getPosition: function (d) { return d.p; },
getColor: function (d) {
return mode === 'ci' ? ciColor(d.ci) : magColor(d.mag);
},
pointSize: BASE_SIZE[g] * sizeScale,
sizeUnits: 'pixels',
opacity: 0.92,
material: false,
pickable: false
}));
}
return layers;
}
var deckgl = new deck.Deck({
canvas: 'cv',
width: '100%',
height: '100%',
views: new deck.OrbitView({ target: [0, 0, 0], fovy: 30 }),
initialViewState: { target: [0, 0, 0], rotationX: 28, rotationOrbit: -22, zoom: 0.3 },
controller: true,
layers: buildLayers()
});
var modeEl = document.getElementById('mode');
modeEl.addEventListener('click', function () {
mode = mode === 'ci' ? 'mag' : 'ci';
modeEl.className = mode === 'ci' ? 'on' : '';
modeEl.textContent = mode === 'ci' ? '按色指数' : '按星等';
deckgl.setProps({ layers: buildLayers() });
});
var sizeEl = document.getElementById('size');
sizeEl.addEventListener('input', function () {
sizeScale = +sizeEl.value;
document.getElementById('ps').textContent = sizeScale.toFixed(1);
deckgl.setProps({ layers: buildLayers() });
});
window.__deck = deckgl;
})();
</script>
</body>
</html>