@johnmorrisdotca/wakusei-planets 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +36 -8
- package/dist/blackbody.d.ts +2 -0
- package/dist/blackbody.js +10 -0
- package/dist/element.d.ts +8 -0
- package/dist/element.js +102 -16
- package/dist/embed.d.ts +3 -0
- package/dist/embed.js +30 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/kids/data.d.ts +109 -0
- package/dist/kids/data.js +164 -0
- package/dist/kids/index.d.ts +4 -0
- package/dist/kids/index.js +5 -0
- package/dist/kids/land.d.ts +3 -0
- package/dist/kids/land.js +29 -0
- package/dist/kids/picture.d.ts +39 -0
- package/dist/kids/picture.js +255 -0
- package/dist/kids/sheet.d.ts +60 -0
- package/dist/kids/sheet.js +79 -0
- package/dist/kids/svg.d.ts +46 -0
- package/dist/kids/svg.js +193 -0
- package/dist/line.d.ts +9 -1
- package/dist/line.js +3 -4
- package/dist/scene/body.d.ts +8 -1
- package/dist/scene/body.js +33 -9
- package/dist/scene/glsl.d.ts +7 -2
- package/dist/scene/glsl.js +49 -3
- package/dist/scene/look.d.ts +43 -0
- package/dist/scene/look.js +39 -1
- package/dist/scene/store.d.ts +3 -0
- package/dist/scene/store.js +3 -1
- package/dist/scene/textures.d.ts +2 -2
- package/dist/star-line.d.ts +20 -0
- package/dist/star-line.js +59 -0
- package/dist/star.d.ts +193 -0
- package/dist/star.js +261 -0
- package/dist/stars.js +3 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -2
package/dist/star.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// A star drawn from numbers: its temperature gives the colour, its radius the size, its luminosity class the grain of its surface, its rotation how it turns, its activity the spots, its oblateness
|
|
2
|
+
// the shape and the darker equator. Nothing here is a photograph and the package holds no catalogue of stars: the page hands over the numbers. Pure: strings and numbers, no DOM, no three.js.
|
|
3
|
+
import { blackBodyRgb } from "./blackbody.js";
|
|
4
|
+
import { BODIES } from "./facts.js";
|
|
5
|
+
/**
|
|
6
|
+
* A star's luminosity class, as the spectral type writes it: `0` a hypergiant, `Ia`, `Iab` and `Ib` supergiants, `II` a bright giant, `III` a giant, `IV` a subgiant, `V` a dwarf (the Sun is G2 V), `VI` a subdwarf and `D` a white dwarf.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { LUMINOSITY_CLASSES, type LuminosityClass } from "@johnmorrisdotca/wakusei-planets";
|
|
11
|
+
*
|
|
12
|
+
* const supergiant: LuminosityClass = LUMINOSITY_CLASSES[1];
|
|
13
|
+
* console.log(supergiant, LUMINOSITY_CLASSES.length);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const LUMINOSITY_CLASSES = ["0", "Ia", "Iab", "Ib", "II", "III", "IV", "V", "VI", "D"];
|
|
17
|
+
const SUN_K = 5772;
|
|
18
|
+
const SUN_R_KM = 695_700;
|
|
19
|
+
/** How long the Sun takes to turn once at its equator, in days, and the turn a page shows for it, in degrees a second. */
|
|
20
|
+
const SUN_DAYS = 25.38;
|
|
21
|
+
const TURN = 12;
|
|
22
|
+
/**
|
|
23
|
+
* The Sun as numbers: the first example of a star, and the size the others are drawn beside.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { STAR_SUN, starLook } from "@johnmorrisdotca/wakusei-planets";
|
|
28
|
+
*
|
|
29
|
+
* console.log(STAR_SUN.temperatureK, starLook(STAR_SUN).turn.degreesPerSecond);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const STAR_SUN = { name: "Sun", temperatureK: SUN_K, radiusSun: 1, luminosityClass: "V", rotationDays: SUN_DAYS };
|
|
33
|
+
function within(name, value, low, high) {
|
|
34
|
+
if (!Number.isFinite(value) || value < low || value > high)
|
|
35
|
+
throw new RangeError(`${name} must be a number from ${low} to ${high}, got ${String(value)}`);
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
const clamp = (v, low, high) => Math.min(high, Math.max(low, v));
|
|
39
|
+
const lerp = (table, x) => {
|
|
40
|
+
if (x <= table[0][0])
|
|
41
|
+
return table[0][1];
|
|
42
|
+
for (let i = 1; i < table.length; i += 1) {
|
|
43
|
+
const [x1, y1] = table[i];
|
|
44
|
+
if (x <= x1) {
|
|
45
|
+
const [x0, y0] = table[i - 1];
|
|
46
|
+
return y0 + ((y1 - y0) * (x - x0)) / (x1 - x0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return table[table.length - 1][1];
|
|
50
|
+
};
|
|
51
|
+
/** How spotted a star is when the page does not say: none on hot stars, many on cool dwarfs and red dwarfs, fewer on giants (their spots are big and few). */
|
|
52
|
+
function defaultActivity(temperatureK, cls, rotationDays) {
|
|
53
|
+
if (cls === "D")
|
|
54
|
+
return 0;
|
|
55
|
+
let a = lerp([[3000, 0.85], [3800, 0.8], [4500, 0.6], [SUN_K, 0.35], [6500, 0.15], [7000, 0.02], [7500, 0]], temperatureK);
|
|
56
|
+
if (cls === "0" || cls === "Ia" || cls === "Iab" || cls === "Ib" || cls === "II" || cls === "III")
|
|
57
|
+
a *= 0.55;
|
|
58
|
+
if (rotationDays !== undefined)
|
|
59
|
+
a *= Math.abs(rotationDays) < 5 ? 1.5 : Math.abs(rotationDays) > 60 ? 0.7 : 1;
|
|
60
|
+
return clamp(a, 0, 1);
|
|
61
|
+
}
|
|
62
|
+
/** The coarseness of the surface by class: the noise frequency of the big cells on the unit sphere (the Sun's is 24), and the share of the finer cells in the mix. */
|
|
63
|
+
const GRAIN = { "0": [1.8, 0.3], Ia: [2.2, 0.3], Iab: [2.7, 0.32], Ib: [3.2, 0.35], II: [4.5, 0.4], III: [7, 0.45], IV: [13, 0.5], V: [24, 0.55], VI: [28, 0.55], D: [0, 0] };
|
|
64
|
+
/** How many cell outlines the line drawing has, and how wide each is, in degrees, by class. */
|
|
65
|
+
const CELLS = { "0": [6, 30], Ia: [7, 28], Iab: [9, 24], Ib: [12, 20], II: [18, 16], III: [28, 12], IV: [40, 9], V: [60, 6.5], VI: [70, 5], D: [0, 0] };
|
|
66
|
+
/** How strongly a surface shows its cells: full for a cool star, fading through the hot ones whose outer layers are not convecting, none for a white dwarf. */
|
|
67
|
+
const visibility = (temperatureK, cls) => (cls === "D" ? 0 : clamp((9500 - temperatureK) / 3000, 0.12, 1));
|
|
68
|
+
const f = (x) => x.toFixed(4);
|
|
69
|
+
const v3 = (c) => `vec3(${f(c[0])}, ${f(c[1])}, ${f(c[2])})`;
|
|
70
|
+
const unit = (kelvin) => blackBodyRgb(kelvin).map((v) => v / 255);
|
|
71
|
+
const saturate = (c, s) => {
|
|
72
|
+
const l = c[0] * 0.3 + c[1] * 0.59 + c[2] * 0.11;
|
|
73
|
+
return [0, 1, 2].map((i) => clamp(l + (c[i] - l) * s, 0, 1));
|
|
74
|
+
};
|
|
75
|
+
const hex = (c) => `#${[0, 1, 2].map((i) => Math.round(clamp(c[i], 0, 1) * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
76
|
+
/** Deterministic random numbers from a seed, so the same numbers give the same spots. */
|
|
77
|
+
function random(seed) {
|
|
78
|
+
let a = seed >>> 0;
|
|
79
|
+
return () => {
|
|
80
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
81
|
+
let t = a;
|
|
82
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
83
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
84
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const seedOf = (text) => [...text].reduce((h, ch) => Math.imul(h ^ ch.charCodeAt(0), 16777619) >>> 0, 2166136261);
|
|
88
|
+
/** The outlines of a star's cells and spots for the line drawing, as features on the body (longitude and latitude in degrees). */
|
|
89
|
+
function features(cls, gran, activity, key) {
|
|
90
|
+
const rnd = random(seedOf(key));
|
|
91
|
+
const out = [];
|
|
92
|
+
const [count, width] = CELLS[cls];
|
|
93
|
+
const cells = gran < 0.2 ? 0 : Math.round(count * gran);
|
|
94
|
+
const golden = Math.PI * (3 - Math.sqrt(5));
|
|
95
|
+
for (let i = 0; i < cells; i += 1) {
|
|
96
|
+
const z = 1 - (2 * (i + 0.5)) / cells;
|
|
97
|
+
const lat = (Math.asin(z) * 180) / Math.PI;
|
|
98
|
+
const lon = ((((i * golden * 180) / Math.PI) % 360) + 360) % 360 - 180;
|
|
99
|
+
out.push({ kind: "circle", lon, lat, radius: width * (0.55 + 0.35 * rnd()) });
|
|
100
|
+
}
|
|
101
|
+
const spots = Math.round(activity * 14);
|
|
102
|
+
const giant = cls === "0" || cls === "Ia" || cls === "Iab" || cls === "Ib" || cls === "II" || cls === "III";
|
|
103
|
+
const band = 25 + 43 * activity;
|
|
104
|
+
for (let i = 0; i < spots; i += 1) {
|
|
105
|
+
const lat = (rnd() * 2 - 1) * band;
|
|
106
|
+
const lon = rnd() * 360 - 180;
|
|
107
|
+
const radius = giant ? (cls === "III" ? 7 : 12) + rnd() * 5 : 2.2 + rnd() * 2.4;
|
|
108
|
+
out.push({ kind: "circle", lon, lat, radius, fill: true });
|
|
109
|
+
out.push({ kind: "circle", lon, lat, radius: radius * 1.7 });
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
const parts = (s) => {
|
|
114
|
+
const known = (name) => (s.estimated.has(name) ? "estimated" : "measured");
|
|
115
|
+
const ratio = s.radiusSun >= 10 ? Math.round(s.radiusSun).toLocaleString("en-US") : String(Number(s.radiusSun.toPrecision(3)));
|
|
116
|
+
const out = [
|
|
117
|
+
{ part: "temperature", status: known("temperatureK"), note: { en: `Surface temperature: ${Math.round(s.temperatureK).toLocaleString("en-US")} K, as given.`, ja: `表面の温度: ${Math.round(s.temperatureK)} K (与えられた数字)。` } },
|
|
118
|
+
{ part: "colour", status: "derived", note: { en: "Colour: a black body at that temperature, the way a camera shows it. It is not a spectrum.", ja: "色: その温度の黒体の色 (カメラで見た色)。スペクトルではありません。" } },
|
|
119
|
+
{ part: "size", status: known("radiusSun"), note: { en: `Size: ${ratio} times the Sun's radius, as given.`, ja: `大きさ: 太陽の半径の${ratio}倍 (与えられた数字)。` } },
|
|
120
|
+
{ part: "edge", status: "derived", note: { en: "Edge darkening: worked out from the temperature, roughly.", ja: "ふちの暗さ: 温度からおおよそ計算しています。" } },
|
|
121
|
+
{ part: "surface", status: "illustrative", note: { en: `Surface texture: how coarse it is follows the luminosity class (${s.cls}); the pattern itself is invented.`, ja: `表面のもよう: 細かさは明るさの階級 (${s.cls}) で決めています。もようは作りものです。` } },
|
|
122
|
+
{ part: "spots", status: "illustrative", note: { en: "Spots: how many follows the temperature and the class; where they are is invented. They are not observations.", ja: "黒点: 数は温度と階級から決めています。場所は作りものです。観測ではありません。" } },
|
|
123
|
+
];
|
|
124
|
+
if (s.rotationDays === undefined)
|
|
125
|
+
out.push({ part: "rotation", status: "illustrative", note: { en: "Turning: no rotation was given, so a slow turn is drawn.", ja: "自転: 数字がないので、ゆっくり回しています。" } });
|
|
126
|
+
else {
|
|
127
|
+
const times = s.speedUp === undefined ? "" : Math.round(s.speedUp).toLocaleString("en-US");
|
|
128
|
+
out.push({ part: "rotation", status: known("rotationDays"), note: { en: `Turning: one turn in ${Number(Math.abs(s.rotationDays).toPrecision(3))} days, shown ${times} times faster than real.`, ja: `自転: 1周${Number(Math.abs(s.rotationDays).toPrecision(3))}日。実際の${times}倍の速さで見せています。` } });
|
|
129
|
+
}
|
|
130
|
+
if (s.oblateness > 0) {
|
|
131
|
+
out.push({ part: "shape", status: known("oblateness"), note: { en: `Shape: flattened by ${Number(s.oblateness.toPrecision(2))}, as given.`, ja: `形: ${Number(s.oblateness.toPrecision(2))}だけつぶれています (与えられた数字)。` } });
|
|
132
|
+
out.push({ part: "poles", status: "derived", note: { en: "Hotter poles and a darker equator (gravity darkening): worked out from the flattening.", ja: "極は熱く、赤道は暗い (重力暗化): つぶれ方から計算しています。" } });
|
|
133
|
+
}
|
|
134
|
+
if (s.prominence)
|
|
135
|
+
out.push({ part: "prominences", status: "illustrative", note: { en: "Prominences and flares on the edge: drawn for looks on an active star, not observed.", ja: "ふちの炎 (プロミネンスやフレア): 活発な星に見た目のために描いています。観測ではありません。" } });
|
|
136
|
+
out.push({ part: "glow", status: "illustrative", note: { en: "The soft glow round the star is for looks, not a measurement.", ja: "星のまわりのやわらかい光は、見た目のための作りものです。" } });
|
|
137
|
+
return out;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Everything the package draws a star with, from the numbers alone: the same numbers always give the same star. Throws a `RangeError` that names the number when one is out of range.
|
|
141
|
+
*
|
|
142
|
+
* The colour is the black body of `temperatureK`. The surface is grained by the luminosity class (and faint on hot stars, smooth on a white dwarf), spotted by `activity` (none on hot stars by default, many on
|
|
143
|
+
* cool dwarfs), darker toward the edge by the temperature, flattened by `oblateness` with hotter poles, and ringed with a soft corona. The cells and the spots are invented; `parts` says which parts are not.
|
|
144
|
+
*
|
|
145
|
+
* @param numbers - The star's numbers.
|
|
146
|
+
* @param options - `quality: "low"` for a cheaper drawing for weak devices (no boiling granulation, no prominences or flares); the default is `full`.
|
|
147
|
+
* @returns The star ready to draw.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* import { starLook } from "@johnmorrisdotca/wakusei-planets";
|
|
152
|
+
*
|
|
153
|
+
* const rigel = starLook({ name: "Rigel", temperatureK: 12100, radiusSun: 78.9, luminosityClass: "Ia", rotationDays: 25 });
|
|
154
|
+
* console.log(rigel.colour, rigel.activity, rigel.parts.filter((part) => part.status === "illustrative").length);
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export function starLook(numbers, options = {}) {
|
|
158
|
+
const low = options.quality === "low";
|
|
159
|
+
const temperatureK = within("temperatureK", numbers.temperatureK, 1000, 200_000);
|
|
160
|
+
const radiusSun = within("radiusSun", numbers.radiusSun, 1e-4, 5000);
|
|
161
|
+
const cls = numbers.luminosityClass ?? "V";
|
|
162
|
+
if (!LUMINOSITY_CLASSES.includes(cls))
|
|
163
|
+
throw new RangeError(`luminosityClass must be one of ${LUMINOSITY_CLASSES.join(", ")}, got ${String(cls)}`);
|
|
164
|
+
const rotationDays = numbers.rotationDays === undefined ? undefined : within("rotationDays", numbers.rotationDays, -1e6, 1e6);
|
|
165
|
+
if (rotationDays === 0)
|
|
166
|
+
throw new RangeError("rotationDays must not be 0: leave it out when the rotation is not known");
|
|
167
|
+
const oblateness = numbers.oblateness === undefined ? 0 : within("oblateness", numbers.oblateness, 0, 0.4);
|
|
168
|
+
const corona = numbers.corona === undefined ? 0.8 : within("corona", numbers.corona, 0, 1);
|
|
169
|
+
const activity = numbers.activity === undefined ? defaultActivity(temperatureK, cls, rotationDays) : within("activity", numbers.activity, 0, 1);
|
|
170
|
+
const name = numbers.name !== undefined && numbers.name.trim() !== "" ? numbers.name.trim() : "Star";
|
|
171
|
+
const estimated = new Set(numbers.estimated ?? []);
|
|
172
|
+
// colour: the black body for the cells, a cooler and more saturated one for the lanes between them
|
|
173
|
+
const body = unit(temperatureK);
|
|
174
|
+
const cell = saturate(unit(temperatureK * 1.06), 2);
|
|
175
|
+
const lane = saturate(unit(temperatureK * (0.62 + 0.3 * clamp((temperatureK - 5000) / 7000, 0, 1))), 2.6).map((v) => v * 0.85);
|
|
176
|
+
const gran = visibility(temperatureK, cls);
|
|
177
|
+
const [grainFreq, grainFine] = GRAIN[cls];
|
|
178
|
+
const band = 25 + 43 * activity;
|
|
179
|
+
const threshold = 0.74 - 0.2 * activity;
|
|
180
|
+
const spotFreq = cls === "0" || cls === "Ia" ? 2 : cls === "Iab" || cls === "Ib" || cls === "II" ? 2.6 : cls === "III" ? 3.4 : temperatureK < 3900 ? 6.5 : 5;
|
|
181
|
+
// gravity darkening: the pole is hotter than the equator by (1 - 3e)^beta, beta 0.25 for a star whose envelope is radiative and 0.08 for a convective one (von Zeipel; Lucy)
|
|
182
|
+
const beta = temperatureK > 7000 ? 0.25 : 0.08;
|
|
183
|
+
const eq = oblateness > 0 ? Math.pow(Math.max(0.05, 1 - 3 * oblateness), beta) : 1;
|
|
184
|
+
const pole = (2 * temperatureK) / (1 + eq);
|
|
185
|
+
const ratioAt = (k) => {
|
|
186
|
+
const c = unit(k);
|
|
187
|
+
const b = (k / temperatureK) ** 2;
|
|
188
|
+
return [c[0] / body[0] * b, c[1] / body[1] * b, c[2] / body[2] * b];
|
|
189
|
+
};
|
|
190
|
+
const grain = cls === "D"
|
|
191
|
+
? "float cell = 0.8;"
|
|
192
|
+
: low
|
|
193
|
+
? `float g = fbm(p * ${f(grainFreq)});
|
|
194
|
+
float g2 = fbm(p * ${f(grainFreq * 2.9)} + 4.0);
|
|
195
|
+
float cell = mix(0.8, smoothstep(0.32, 0.72, mix(g, g2, ${f(grainFine)})), ${f(gran)});`
|
|
196
|
+
: `float boil = 0.5 + 0.5 * sin(uTime * 0.35);
|
|
197
|
+
float g = fbm(p * ${f(grainFreq)} + vec3(0.0, 0.0, uTime * 0.004));
|
|
198
|
+
float g2 = mix(fbm(p * ${f(grainFreq * 2.9)} + 4.0), fbm(p * ${f(grainFreq * 2.9)} + 11.0), boil);
|
|
199
|
+
float cell = mix(0.8, smoothstep(0.32, 0.72, mix(g, g2, ${f(grainFine)})), ${f(gran)});`;
|
|
200
|
+
const shape = oblateness > 0 ? `\n col *= mix(${v3(ratioAt(pole))}, ${v3(ratioAt(eq * pole))}, 1.0 - p.z * p.z);` : "";
|
|
201
|
+
const spots = activity > 0.02
|
|
202
|
+
? `
|
|
203
|
+
float act = smoothstep(radians(${f(band)}), radians(8.0), abs(lat(p)));
|
|
204
|
+
float sn = fbm(p * ${f(spotFreq)} + 3.0);
|
|
205
|
+
float spot = smoothstep(${f(threshold)}, ${f(threshold + 0.08)}, sn) * act;
|
|
206
|
+
float pen = smoothstep(${f(threshold - 0.07)}, ${f(threshold)}, sn) * act;
|
|
207
|
+
col = mix(col, ${v3(lane.map((v) => v * 0.6))}, pen * 0.55);
|
|
208
|
+
col = mix(col, ${v3(lane.map((v) => v * 0.16))}, spot * 0.92);`
|
|
209
|
+
: "";
|
|
210
|
+
const surface = `${low || cls === "D" ? "" : "\nuniform float uTime;"}
|
|
211
|
+
vec4 surface(vec3 p) {
|
|
212
|
+
${grain}
|
|
213
|
+
vec3 col = mix(${v3(lane)}, ${v3(cell)}, cell);${low ? "" : "\n col *= 0.8 + 0.4 * smoothstep(0.1, 0.9, cell);"}${shape}${spots}
|
|
214
|
+
return vec4(col * 1.12, 0.0);
|
|
215
|
+
}`;
|
|
216
|
+
// the edge: the exponent of the limb darkening, and the colour the edge shifts to (a cooler layer seen at a slant)
|
|
217
|
+
const limb = clamp(0.5 + (SUN_K - temperatureK) / 30_000, 0.2, 0.7);
|
|
218
|
+
const cool = unit(temperatureK * 0.78);
|
|
219
|
+
const tint = [0, 1, 2].map((i) => Math.min(1, (cool[i] / body[i]) ** 1.4));
|
|
220
|
+
const glowColour = saturate(body, 1.1);
|
|
221
|
+
const spread = clamp(2.4 + (SUN_K - temperatureK) / 12_000, 1.7, 3.4);
|
|
222
|
+
const prominence = low || activity < 0.15 ? 0 : clamp(activity * 1.1, 0, 1);
|
|
223
|
+
const speedReal = rotationDays === undefined ? undefined : 360 / (Math.abs(rotationDays) * 86_400);
|
|
224
|
+
const shown = rotationDays === undefined ? TURN : clamp(TURN * (SUN_DAYS / Math.abs(rotationDays)) ** 0.4, 2, 60);
|
|
225
|
+
const degreesPerSecond = (rotationDays !== undefined && rotationDays < 0 ? -1 : 1) * shown;
|
|
226
|
+
const speedUp = speedReal === undefined ? undefined : shown / speedReal;
|
|
227
|
+
const key = JSON.stringify([low ? "low" : "full", name, temperatureK, radiusSun, cls, rotationDays ?? null, activity, oblateness, corona]);
|
|
228
|
+
const colour = hex(body);
|
|
229
|
+
const look = { id: "sun", surface, emissive: true, limb, limbTint: tint, glow: { colour: glowColour, strength: 0.62 * corona, spread, rim: 0.3 * corona, prominence, seed: (seedOf(key) % 1000) / 1000 } };
|
|
230
|
+
const facts = {
|
|
231
|
+
...BODIES.sun,
|
|
232
|
+
name: { en: name, ja: name === "Star" ? "恒星" : name },
|
|
233
|
+
radiusKm: radiusSun * SUN_R_KM,
|
|
234
|
+
flattening: oblateness,
|
|
235
|
+
rotationHours: (rotationDays ?? SUN_DAYS) * 24,
|
|
236
|
+
colour,
|
|
237
|
+
features: features(cls, gran, activity, key),
|
|
238
|
+
};
|
|
239
|
+
const lines = parts({ temperatureK, radiusSun, cls, rotationDays, oblateness, speedUp, estimated, prominence: prominence > 0 });
|
|
240
|
+
return {
|
|
241
|
+
numbers,
|
|
242
|
+
name,
|
|
243
|
+
temperatureK,
|
|
244
|
+
radiusSun,
|
|
245
|
+
radiusKm: radiusSun * SUN_R_KM,
|
|
246
|
+
quality: low ? "low" : "full",
|
|
247
|
+
luminosityClass: cls,
|
|
248
|
+
rotationDays,
|
|
249
|
+
activity,
|
|
250
|
+
oblateness,
|
|
251
|
+
corona,
|
|
252
|
+
colour,
|
|
253
|
+
tone: hex(cell),
|
|
254
|
+
look,
|
|
255
|
+
facts,
|
|
256
|
+
turn: { degreesPerSecond, speedUp },
|
|
257
|
+
parts: lines,
|
|
258
|
+
disclaimer: { en: `${name}: drawn from its numbers, not a photo.`, ja: `${name}: 数字から描いた絵で、写真ではありません。` },
|
|
259
|
+
key,
|
|
260
|
+
};
|
|
261
|
+
}
|
package/dist/stars.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The stars you can see without a telescope: the 5,080 of the Yale Bright Star Catalogue to visual magnitude 6.0, with their names, positions, proper motion, brightness and colour.
|
|
2
2
|
// An opt-in entry point (`@johnmorrisdotca/wakusei-planets/stars`): the table is about 100 kB gzipped and nothing else imports it. Pure: no DOM, no three.js, no state beyond the parsed table.
|
|
3
3
|
import { J2000_MS } from "./clock.js";
|
|
4
|
+
import { blackBodyRgb } from "./blackbody.js";
|
|
4
5
|
import { STAR_NAMES, STAR_ROWS } from "./data/stars.js";
|
|
5
6
|
import { moment } from "./when.js";
|
|
6
7
|
const stored = [];
|
|
@@ -168,11 +169,8 @@ export function starTemperatureK(colourIndex) {
|
|
|
168
169
|
export function blackBodyColour(kelvin) {
|
|
169
170
|
if (!Number.isFinite(kelvin) || kelvin <= 0)
|
|
170
171
|
throw new RangeError(`kelvin must be a positive number, got ${kelvin}`);
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const green = t <= 66 ? 99.4708025861 * Math.log(t) - 161.1195681661 : 288.1221695283 * (t - 60) ** -0.0755148492;
|
|
174
|
-
const blue = t >= 66 ? 255 : t <= 19 ? 0 : 138.5177312231 * Math.log(t - 10) - 305.0447927307;
|
|
175
|
-
const byte = (v) => Math.round(Math.min(255, Math.max(0, v))).toString(16).padStart(2, "0");
|
|
172
|
+
const [red, green, blue] = blackBodyRgb(kelvin);
|
|
173
|
+
const byte = (v) => Math.round(v).toString(16).padStart(2, "0");
|
|
176
174
|
return `#${byte(red)}${byte(green)}${byte(blue)}`;
|
|
177
175
|
}
|
|
178
176
|
/**
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.25.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.25.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|
|
@@ -139,6 +139,11 @@
|
|
|
139
139
|
"import": "./dist/stars.js",
|
|
140
140
|
"default": "./dist/stars.js"
|
|
141
141
|
},
|
|
142
|
+
"./sheets": {
|
|
143
|
+
"types": "./dist/kids/index.d.ts",
|
|
144
|
+
"import": "./dist/kids/index.js",
|
|
145
|
+
"default": "./dist/kids/index.js"
|
|
146
|
+
},
|
|
142
147
|
"./nearest": {
|
|
143
148
|
"types": "./dist/nearest.d.ts",
|
|
144
149
|
"import": "./dist/nearest.js",
|
|
@@ -317,6 +322,7 @@
|
|
|
317
322
|
"node": ">=24"
|
|
318
323
|
},
|
|
319
324
|
"scripts": {
|
|
325
|
+
"export:data": "node scripts/export-data.ts",
|
|
320
326
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/copy-textures.mjs",
|
|
321
327
|
"lint": "eslint .",
|
|
322
328
|
"typecheck": "tsc -p tsconfig.check.json && tsc -p tsconfig.tools.json && tsc -p tsconfig.demo.json",
|
|
@@ -379,7 +385,7 @@
|
|
|
379
385
|
},
|
|
380
386
|
"packageManager": "pnpm@10.28.0",
|
|
381
387
|
"dependencies": {
|
|
382
|
-
"@johnmorrisdotca/kazoku-ui": "^0.
|
|
388
|
+
"@johnmorrisdotca/kazoku-ui": "^0.22.0"
|
|
383
389
|
},
|
|
384
390
|
"peerDependencies": {
|
|
385
391
|
"@johnmorrisdotca/chikyu-earth": ">=0.10.0",
|