@johnmorrisdotca/chikyu-earth 0.28.0 → 0.30.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 CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.30.0 - 2026-11-11
6
+
7
+ - **A strength setting for the meteors** (MODULES-906). `meteors-strength` (the property `meteorsStrength`) on `<chikyu-earth-realistic>` and `<chikyu-space>` is a number from 0 to 1 that scales how bright each streak is and how many are drawn, so a page can show them subtly. It is 1, the look they have always had, when the page says nothing; a number outside the range is brought to its nearest end and one that is not a number is 1. At 0 no streak is drawn, and the line under the picture, the survey of the sky and `chikyu-meteors` are as they were. Nothing that is real changes at any strength: the hourly rates and the showers' `zhr` are the same, and the line still says the streaks are an illustration. `stats.meteors` gains `strength` (and its `perSecond` is the streaks a second drawn, so it follows the strength). New in `@johnmorrisdotca/chikyu-earth/meteors`: `readMeteorStrength`, `METEOR_STRENGTH_DEFAULT`, and `streaksPerSecond(rate, strength)`. The demo has a Subtle, Medium and Full choice beside the Meteors button (`meteors-strength` in the address). The guide, in English and Japanese, has a section on it.
8
+
9
+ ## 0.29.0 - 2026-11-11
10
+
11
+ - **The air is drawn 3 times its real thickness unless a page says otherwise, so the ring can be seen** (MODULES-904). At whole-Earth zoom the true 100 km shell is a line a pixel or two wide, and on a phone thinner than the old painted glow. `air-thickness` (and the property `airThickness`) on `<chikyu-earth-realistic>` and `<chikyu-space>` takes a number from 1 (the true thickness) to 5, and 3 when left out; the shell and the heights over which the air thins grow by it and the air is the same amount, so the physics and the colours do not change. While it is above 1 the element says so in a line under the picture, "The air is drawn 3 times its real thickness so it can be seen." (and in Japanese), which `air-label="off"` takes away. New exports `AIR_THICKNESS_DEFAULT`, `AIR_THICKNESS_MAX`, `readAirThickness`, `airTop` and `AIR_NOTE`. The demo has a True air thickness button on the realistic and space looks and on the full-screen page (`air-thickness=1` in the address). The cost is the same: a draw is the same program with one more uniform. Tests: `test/air.test.ts`, `e2e/air-visible.gl.ts`.
12
+
5
13
  ## 0.28.0 - 2026-11-11
6
14
 
7
15
  - **The air is light scattered once, worked out in the shader** (MODULES-843). The realistic Earth and the space view draw the atmosphere as a shell 100 km thick (0.0157 of the Earth's radius), sampled along each ray toward the camera and toward the Sun in the fragment shader, with the samples packed where the air is thick: Rayleigh scattering (a blue haze that thickens toward the limb on the day side), Mie scattering (a glow toward the Sun), the reddening along the day and night line, and the thin lit ring seen from the night side looking toward the Sun are what the sums give, not things drawn. The surface under it is dimmed by what the air takes out of the light. The old rim in the surface program is gone. Our own code, from the published single-scattering model (Nishita and others, 1993; GPU Gems 2, chapter 16), no code taken from any project. `air="light"` (6 samples along the ray and 2 toward the Sun; the default on a small or slow device) or `air="full"` (12 and 4), on both elements. It costs nothing at rest, at most 30 frames a second as before. New in `/realistic`: `AIR_TOP`, `AIR_QUALITY`, `AIR_VERT`, `airFrag`, `airFor` and `AirSamples`. `ATMOSPHERE_OUTER` stays the room the page leaves for it. Guide in English and Japanese: `docs/guides/full-screen-and-camera.md`.
package/README.md CHANGED
@@ -189,7 +189,7 @@ computed in the browser by astronomy-engine (MIT), nothing is fetched. [docs/spa
189
189
 
190
190
  ## Meteors
191
191
 
192
- `<chikyu-earth-realistic meteors>` and `<chikyu-space meteors>` draw meteors as they look from space: short streaks 80 to 120 km up, only on the dark side and in twilight, more of them under an active shower's radiant, and only while the clock runs. Each streak's place and moment are drawn at random, and the element says so under the picture; how many there are, where they fall, their height and the showers' dates are real. The showers are the International Meteor Organization's working list for 2026 (37 of them), in an entry point of its own with the rate functions, which needs no browser: [guide](docs/guides/meteors.md).
192
+ `<chikyu-earth-realistic meteors>` and `<chikyu-space meteors>` draw meteors as they look from space: short streaks 80 to 120 km up, only on the dark side and in twilight, more of them under an active shower's radiant, and only while the clock runs. Each streak's place and moment are drawn at random, and the element says so under the picture; how many there are, where they fall, their height and the showers' dates are real. `meteors-strength` (0 to 1, the property `meteorsStrength`; 1 when you say nothing) makes them subtler: fewer streaks and fainter ones, none at 0, with every real figure unchanged. The showers are the International Meteor Organization's working list for 2026 (37 of them), in an entry point of its own with the rate functions, which needs no browser: [guide](docs/guides/meteors.md).
193
193
 
194
194
  ```js
195
195
  import { activeShowers } from "@johnmorrisdotca/chikyu-earth/meteors";
@@ -489,7 +489,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
489
489
 
490
490
  ## How to cite
491
491
 
492
- > Morris, J. (2026). *Chikyu Earth* (version 0.28.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
492
+ > Morris, J. (2026). *Chikyu Earth* (version 0.30.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
493
493
 
494
494
  GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
495
495
 
@@ -1,3 +1,4 @@
1
1
  export { METEOR_SHOWERS, type MeteorShower } from "../data/meteor-showers.ts";
2
2
  export { METEOR_HEIGHT_KM, SPORADIC_HOURLY_RATE, activeShowers, apexPoint, darkness, hourlyRateAt, meteorSky, placeVector, pointBeneath, showerRate, solarLongitude, type MeteorSky } from "./rate.ts";
3
3
  export { METEORS_PER_SECOND_MAX, METEOR_SLOTS, streakPath, streaksPerSecond } from "./layer.ts";
4
+ export { METEOR_STRENGTH_DEFAULT, readMeteorStrength } from "./strength.ts";
@@ -4,3 +4,4 @@
4
4
  export { METEOR_SHOWERS } from "../data/meteor-showers.js";
5
5
  export { METEOR_HEIGHT_KM, SPORADIC_HOURLY_RATE, activeShowers, apexPoint, darkness, hourlyRateAt, meteorSky, placeVector, pointBeneath, showerRate, solarLongitude } from "./rate.js";
6
6
  export { METEORS_PER_SECOND_MAX, METEOR_SLOTS, streakPath, streaksPerSecond } from "./layer.js";
7
+ export { METEOR_STRENGTH_DEFAULT, readMeteorStrength } from "./strength.js";
@@ -32,6 +32,8 @@ export interface MeteorState {
32
32
  running: () => boolean;
33
33
  /** Told when the strongest active shower changes, with `null` when none is active. */
34
34
  onShower?: (shower: MeteorShower | null, zhr: number) => void;
35
+ /** How strongly the streaks are drawn, 0 to 1 (`meteors-strength`): it scales how many start and how bright they are, and nothing that is real. 0 draws none. */
36
+ strength: number;
35
37
  random: () => number;
36
38
  drawn: {
37
39
  alive: number;
@@ -66,18 +68,20 @@ export interface MeteorLayer {
66
68
  * How many streaks a second are drawn for a mean hourly rate over the dark part of the view: 2.5 a second where the whole view is dark on a
67
69
  * night with no shower, more with a shower but squeezed (the 0.6th power) and never over nine, none where nothing in view is dark.
68
70
  * A streak stands for a great many meteors: the count follows the real rate, it does not equal it.
71
+ * `strength` (0 to 1, the page's `meteors-strength`) then scales the count: half the streaks at 0.5, none at 0.
69
72
  *
70
73
  * @param meanHourlyRate - The mean over the view of each place's hourly rate times how dark it is there (`hourlyRateAt`, `darkness`).
74
+ * @param strength - How strongly the streaks are drawn, from 0 to 1 (1 when left out); a number outside the range is brought to its nearest end.
71
75
  * @returns Streaks a second.
72
76
  *
73
77
  * @example
74
78
  * ```ts
75
79
  * import { streaksPerSecond } from "@johnmorrisdotca/chikyu-earth/meteors";
76
80
  *
77
- * console.log(streaksPerSecond(8), streaksPerSecond(0), streaksPerSecond(100000)); // 2.5 0 9
81
+ * console.log(streaksPerSecond(8), streaksPerSecond(0), streaksPerSecond(100000), streaksPerSecond(8, 0.5)); // 2.5 0 9 1.25
78
82
  * ```
79
83
  */
80
- export declare function streaksPerSecond(meanHourlyRate: number): number;
84
+ export declare function streaksPerSecond(meanHourlyRate: number, strength?: number): number;
81
85
  /**
82
86
  * Where one streak runs: from `start` to `end`, in Earth radii from the centre, in the Earth's own axes.
83
87
  * It ends `METEOR_HEIGHT_KM.bottom + 5` km up and comes down the line from the radiant; its true length is the drop in height
@@ -1,4 +1,5 @@
1
1
  import { METEOR_HEIGHT_KM, SPORADIC_HOURLY_RATE, darkness, hourlyRateAt, meteorSky } from "./rate.js";
2
+ import { METEOR_STRENGTH_DEFAULT } from "./strength.js";
2
3
  const EARTH_KM = 6371;
3
4
  /**
4
5
  * The most streaks alive at once: the size of the one mesh they are drawn as.
@@ -37,32 +38,35 @@ const SAMPLES = 160;
37
38
  /** The Earth's radius on the screen, in CSS pixels, below which no streak is drawn. */
38
39
  const MIN_EARTH_PX = 40;
39
40
  const FRAME_MS = 33;
40
- export const newMeteorState = () => ({ on: false, running: () => false, random: Math.random, drawn: { alive: 0, spawned: 0, perSecond: 0, shower: null, zhr: 0 } });
41
+ export const newMeteorState = () => ({ on: false, running: () => false, strength: METEOR_STRENGTH_DEFAULT, random: Math.random, drawn: { alive: 0, spawned: 0, perSecond: 0, shower: null, zhr: 0 } });
41
42
  /**
42
43
  * How many streaks a second are drawn for a mean hourly rate over the dark part of the view: 2.5 a second where the whole view is dark on a
43
44
  * night with no shower, more with a shower but squeezed (the 0.6th power) and never over nine, none where nothing in view is dark.
44
45
  * A streak stands for a great many meteors: the count follows the real rate, it does not equal it.
46
+ * `strength` (0 to 1, the page's `meteors-strength`) then scales the count: half the streaks at 0.5, none at 0.
45
47
  *
46
48
  * @param meanHourlyRate - The mean over the view of each place's hourly rate times how dark it is there (`hourlyRateAt`, `darkness`).
49
+ * @param strength - How strongly the streaks are drawn, from 0 to 1 (1 when left out); a number outside the range is brought to its nearest end.
47
50
  * @returns Streaks a second.
48
51
  *
49
52
  * @example
50
53
  * ```ts
51
54
  * import { streaksPerSecond } from "@johnmorrisdotca/chikyu-earth/meteors";
52
55
  *
53
- * console.log(streaksPerSecond(8), streaksPerSecond(0), streaksPerSecond(100000)); // 2.5 0 9
56
+ * console.log(streaksPerSecond(8), streaksPerSecond(0), streaksPerSecond(100000), streaksPerSecond(8, 0.5)); // 2.5 0 9 1.25
54
57
  * ```
55
58
  */
56
- export function streaksPerSecond(meanHourlyRate) {
57
- if (!(meanHourlyRate > 0))
59
+ export function streaksPerSecond(meanHourlyRate, strength = METEOR_STRENGTH_DEFAULT) {
60
+ if (!(meanHourlyRate > 0) || !(strength > 0))
58
61
  return 0;
59
- return Math.min(METEORS_PER_SECOND_MAX, BASE_PER_SECOND * Math.pow(meanHourlyRate / SPORADIC_HOURLY_RATE, 0.6));
62
+ return Math.min(METEORS_PER_SECOND_MAX, BASE_PER_SECOND * Math.pow(meanHourlyRate / SPORADIC_HOURLY_RATE, 0.6)) * Math.min(1, strength);
60
63
  }
61
64
  const VERT = /* glsl */ `
62
65
  uniform float now;
63
66
  uniform float vw;
64
67
  uniform float vh;
65
68
  uniform float thick;
69
+ uniform float strength;
66
70
  attribute vec3 aStart;
67
71
  attribute vec3 aEnd;
68
72
  attribute vec2 aTime;
@@ -88,7 +92,7 @@ void main() {
88
92
  at.xy += push / halfSize * at.w;
89
93
  // a streak is there from its start to a short afterglow, and nowhere before or after
90
94
  float alive = step(0.0, age) * (1.0 - smoothstep(1.0, 1.35, age));
91
- vFade = alive * aGlow * smoothstep(0.0, 0.12, age);
95
+ vFade = alive * aGlow * strength * smoothstep(0.0, 0.12, age);
92
96
  vAlong = aCorner.x;
93
97
  vSide = aCorner.y;
94
98
  gl_Position = alive > 0.0 ? at : vec4(2.0, 2.0, 2.0, 1.0);
@@ -173,7 +177,7 @@ export function createMeteorLayer(three, parent, state) {
173
177
  geometry.setAttribute("aCorner", new three.BufferAttribute(cornerOf, 2));
174
178
  geometry.setAttribute("aGlow", glowAttr);
175
179
  geometry.setIndex(index);
176
- const uniforms = { now: { value: 0 }, vw: { value: 1 }, vh: { value: 1 }, thick: { value: 1.8 }, tint: { value: new three.Vector3(1, 0.96, 0.86) } };
180
+ const uniforms = { now: { value: 0 }, vw: { value: 1 }, vh: { value: 1 }, thick: { value: 1.8 }, strength: { value: 1 }, tint: { value: new three.Vector3(1, 0.96, 0.86) } };
177
181
  const material = new three.ShaderMaterial({ vertexShader: VERT, fragmentShader: FRAG, uniforms, transparent: true, depthWrite: false, side: three.DoubleSide });
178
182
  const mesh = new three.Mesh(geometry, material);
179
183
  mesh.frustumCulled = false;
@@ -185,6 +189,8 @@ export function createMeteorLayer(three, parent, state) {
185
189
  const over = new Float64Array(METEOR_SLOTS);
186
190
  let sky = null;
187
191
  let skyAt = -Infinity;
192
+ /** The strength the sky was last surveyed at: a new one makes the survey again, so the count follows it at once. */
193
+ let surveyedAt = METEOR_STRENGTH_DEFAULT;
188
194
  let peak = 0;
189
195
  let perSecond = 0;
190
196
  let nextAt = 0;
@@ -210,7 +216,8 @@ export function createMeteorLayer(three, parent, state) {
210
216
  if (weight > peak)
211
217
  peak = weight;
212
218
  }
213
- perSecond = streaksPerSecond(sum / SAMPLES);
219
+ surveyedAt = state.strength;
220
+ perSecond = streaksPerSecond(sum / SAMPLES, surveyedAt);
214
221
  const top = sky.showers[0];
215
222
  state.drawn.perSecond = perSecond;
216
223
  state.drawn.shower = top?.shower.code ?? null;
@@ -296,8 +303,18 @@ export function createMeteorLayer(three, parent, state) {
296
303
  mesh.visible = false;
297
304
  return Infinity;
298
305
  }
299
- if (!sky || Math.abs(input.time - sky.ms) > SKY_GAME_MS || input.now - skyAt > SKY_WALL_MS)
306
+ if (!sky || Math.abs(input.time - sky.ms) > SKY_GAME_MS || input.now - skyAt > SKY_WALL_MS || state.strength !== surveyedAt)
300
307
  survey(input);
308
+ uniforms.strength.value = Math.min(1, Math.max(0, state.strength));
309
+ if (!(state.strength > 0)) {
310
+ // strength 0: the sky is still surveyed (the shower is still told) but no streak starts, and nothing more is asked for
311
+ over.fill(0);
312
+ nextAt = 0;
313
+ last = input.now;
314
+ state.drawn.alive = 0;
315
+ mesh.visible = false;
316
+ return Infinity;
317
+ }
301
318
  if (perSecond > 0) {
302
319
  // after a rest the clock starts again from now, so a pause is not made up for with a burst
303
320
  if (input.now - last > 1000 || nextAt === 0)
@@ -0,0 +1,26 @@
1
+ /**
2
+ * How strongly the meteors are drawn when a page says nothing: 1, the look they have always had. The page's `meteors-strength` attribute chooses.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { METEOR_STRENGTH_DEFAULT } from "@johnmorrisdotca/chikyu-earth/meteors";
7
+ *
8
+ * console.log(METEOR_STRENGTH_DEFAULT); // 1
9
+ * ```
10
+ */
11
+ export declare const METEOR_STRENGTH_DEFAULT = 1;
12
+ /**
13
+ * What a page's `meteors-strength` attribute means: a number from 0 (no streaks are drawn) to 1 (the full look), given as it is written; with none, or something that
14
+ * is not a number, `METEOR_STRENGTH_DEFAULT`. A number outside the range is brought to its nearest end.
15
+ *
16
+ * @param given - The attribute's value, or `null` when the page has none.
17
+ * @returns How strongly the streaks are drawn, between 0 and 1.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { readMeteorStrength } from "@johnmorrisdotca/chikyu-earth/meteors";
22
+ *
23
+ * console.log(readMeteorStrength(null), readMeteorStrength("0.3"), readMeteorStrength("7"), readMeteorStrength("-1"), readMeteorStrength("soft")); // 1 0.3 1 0 1
24
+ * ```
25
+ */
26
+ export declare function readMeteorStrength(given: string | null): number;
@@ -0,0 +1,35 @@
1
+ // How strongly the meteors are drawn: one number from 0 to 1 that a page sets with `meteors-strength`. It scales how bright a streak is and how many are drawn.
2
+ // It changes nothing that is real: the hourly rates, the showers and the `chikyu-meteors` event are the same at every strength.
3
+ /**
4
+ * How strongly the meteors are drawn when a page says nothing: 1, the look they have always had. The page's `meteors-strength` attribute chooses.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { METEOR_STRENGTH_DEFAULT } from "@johnmorrisdotca/chikyu-earth/meteors";
9
+ *
10
+ * console.log(METEOR_STRENGTH_DEFAULT); // 1
11
+ * ```
12
+ */
13
+ export const METEOR_STRENGTH_DEFAULT = 1;
14
+ /**
15
+ * What a page's `meteors-strength` attribute means: a number from 0 (no streaks are drawn) to 1 (the full look), given as it is written; with none, or something that
16
+ * is not a number, `METEOR_STRENGTH_DEFAULT`. A number outside the range is brought to its nearest end.
17
+ *
18
+ * @param given - The attribute's value, or `null` when the page has none.
19
+ * @returns How strongly the streaks are drawn, between 0 and 1.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { readMeteorStrength } from "@johnmorrisdotca/chikyu-earth/meteors";
24
+ *
25
+ * console.log(readMeteorStrength(null), readMeteorStrength("0.3"), readMeteorStrength("7"), readMeteorStrength("-1"), readMeteorStrength("soft")); // 1 0.3 1 0 1
26
+ * ```
27
+ */
28
+ export function readMeteorStrength(given) {
29
+ if (given === null || given.trim() === "")
30
+ return METEOR_STRENGTH_DEFAULT;
31
+ const value = Number(given);
32
+ if (!Number.isFinite(value))
33
+ return METEOR_STRENGTH_DEFAULT;
34
+ return Math.min(1, Math.max(0, value));
35
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The line, in the two languages the family's pages are written in; `{n}` is how many times its real thickness the air is drawn.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { AIR_NOTE } from "@johnmorrisdotca/chikyu-earth/realistic";
7
+ * console.log(AIR_NOTE.en.replace("{n}", "3"));
8
+ * ```
9
+ */
10
+ export declare const AIR_NOTE: {
11
+ readonly en: "The air is drawn {n} times its real thickness so it can be seen.";
12
+ readonly ja: "大気は、見やすいように実際の厚さの{n}倍で描いています。";
13
+ };
14
+ /** The styles of the lines under the picture (`#notes`, with the air's `#air-note` and the meteors' `#meteor-note` in it, one above the other) in an element's shadow root. */
15
+ export declare const NOTES_STYLE = "#notes{position:absolute;left:8px;right:8px;bottom:6px;display:flex;flex-direction:column;align-items:flex-start;gap:4px;pointer-events:none}#notes>p{position:static;margin:0;max-width:100%;font:11px/1.3 system-ui,sans-serif;color:#dfe6f2;background:#0b0e14b3;padding:2px 6px;border-radius:4px}#notes>p[hidden]{display:none}";
16
+ /** The words of the line for a thickness: a whole number is written plainly, any other with up to one decimal. */
17
+ export declare function airNoteText(lang: "en" | "ja", thickness: number): string;
18
+ /** Put the line right: its words in the language of the element or the page, shown only while the air is thicker than it is (`air-thickness` above 1) and `air-label` is not `off`. */
19
+ export declare function setAirNote(note: HTMLElement | undefined, host: HTMLElement, thickness: number): void;
@@ -0,0 +1,29 @@
1
+ // The line an element shows under its picture while the air is drawn thicker than it is, so nobody takes the ring for the true size of the atmosphere.
2
+ /**
3
+ * The line, in the two languages the family's pages are written in; `{n}` is how many times its real thickness the air is drawn.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { AIR_NOTE } from "@johnmorrisdotca/chikyu-earth/realistic";
8
+ * console.log(AIR_NOTE.en.replace("{n}", "3"));
9
+ * ```
10
+ */
11
+ export const AIR_NOTE = {
12
+ en: "The air is drawn {n} times its real thickness so it can be seen.",
13
+ ja: "大気は、見やすいように実際の厚さの{n}倍で描いています。",
14
+ };
15
+ /** The styles of the lines under the picture (`#notes`, with the air's `#air-note` and the meteors' `#meteor-note` in it, one above the other) in an element's shadow root. */
16
+ export const NOTES_STYLE = "#notes{position:absolute;left:8px;right:8px;bottom:6px;display:flex;flex-direction:column;align-items:flex-start;gap:4px;pointer-events:none}#notes>p{position:static;margin:0;max-width:100%;font:11px/1.3 system-ui,sans-serif;color:#dfe6f2;background:#0b0e14b3;padding:2px 6px;border-radius:4px}#notes>p[hidden]{display:none}";
17
+ /** The words of the line for a thickness: a whole number is written plainly, any other with up to one decimal. */
18
+ export function airNoteText(lang, thickness) {
19
+ return AIR_NOTE[lang].replace("{n}", String(Math.round(thickness * 10) / 10));
20
+ }
21
+ /** Put the line right: its words in the language of the element or the page, shown only while the air is thicker than it is (`air-thickness` above 1) and `air-label` is not `off`. */
22
+ export function setAirNote(note, host, thickness) {
23
+ if (!note)
24
+ return;
25
+ const lang = (host.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
26
+ note.textContent = airNoteText(lang, thickness);
27
+ note.lang = lang;
28
+ note.hidden = thickness <= 1 || host.getAttribute("air-label") === "off";
29
+ }
@@ -8,6 +8,53 @@
8
8
  * ```
9
9
  */
10
10
  export declare const AIR_TOP: number;
11
+ /**
12
+ * How many times its real thickness the air is drawn when a page says nothing: 3. The air is a shell 100 km thick on a globe 12,742 km across, a hair's breadth, and at whole-Earth zoom it comes to a line a pixel or two wide (on a phone, thinner still);
13
+ * three times is a ring the eye can find, with the same physics and the same colours. `1` is the true thickness. The page's `air-thickness` attribute chooses.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { AIR_THICKNESS_DEFAULT } from "@johnmorrisdotca/chikyu-earth/realistic";
18
+ * console.log(AIR_THICKNESS_DEFAULT);
19
+ * ```
20
+ */
21
+ export declare const AIR_THICKNESS_DEFAULT = 3;
22
+ /**
23
+ * The most the air may be thickened: 5, which is as far as the element's box leaves room for (its top is then 1.0785 Earth radii out, inside the 1.08 the box is fitted to).
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { AIR_THICKNESS_MAX } from "@johnmorrisdotca/chikyu-earth/realistic";
28
+ * console.log(AIR_THICKNESS_MAX);
29
+ * ```
30
+ */
31
+ export declare const AIR_THICKNESS_MAX = 5;
32
+ /**
33
+ * What a page's `air-thickness` attribute means: a number from 1 (the true thickness) to 5, given as it is written; with none, or something that is not a number, `AIR_THICKNESS_DEFAULT`. A number outside the range is brought to its nearest end.
34
+ *
35
+ * @param given - The attribute's value, or `null` when the page has none.
36
+ * @returns How many times its real thickness the air is drawn, between 1 and 5.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { readAirThickness } from "@johnmorrisdotca/chikyu-earth/realistic";
41
+ * console.log(readAirThickness(null), readAirThickness("1"), readAirThickness("9"));
42
+ * ```
43
+ */
44
+ export declare function readAirThickness(given: string | null): number;
45
+ /**
46
+ * Where the air's top is, in Earth radii, when it is drawn `thickness` times its real thickness: 1 plus 100 km times that, over the Earth's 6,371.
47
+ *
48
+ * @param thickness - 1 for the true thickness (the top is then `AIR_TOP`).
49
+ * @returns The radius of the shell's outside, in Earth radii.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { airTop } from "@johnmorrisdotca/chikyu-earth/realistic";
54
+ * console.log(airTop(3).toFixed(4));
55
+ * ```
56
+ */
57
+ export declare const airTop: (thickness: number) => number;
11
58
  /**
12
59
  * How many samples the air takes: along the ray toward the camera and, at each of those, along the ray toward the Sun.
13
60
  *
@@ -63,6 +110,7 @@ export declare const AIR_VERT = "\nvarying vec3 vWorld;\nvoid main() {\n vWorld
63
110
  * the glow toward the Sun, the reddening along the day and night line (the Sun's light has crossed a long, low path) and the thin lit ring seen from the night side looking toward the Sun.
64
111
  * The surface under it is dimmed by what the air takes out of the light (the shader's alpha is what gets through) and what it adds is the colour.
65
112
  * Our own code, from the published single-scattering model (Nishita and others, 1993; O'Neil, GPU Gems 2, chapter 16), no code taken from any project.
113
+ * The air can be drawn thicker than it is (`thick`, a uniform: 1 is the true 100 km, 3 the default of the elements): the shell and both scale heights grow by it and what each unit of length holds shrinks by it, so the same air gives the same colours over a wider glow.
66
114
  * The Sun is in the world's axes (`sunDir`, toward the Sun); `ortho` is 1 when the camera looks down the z axis from far away (the realistic Earth) and 0 for a camera at a place (the space view).
67
115
  *
68
116
  * @param samples - How many samples to take (`AIR_QUALITY.full` or `AIR_QUALITY.light`).
@@ -10,6 +10,60 @@
10
10
  * ```
11
11
  */
12
12
  export const AIR_TOP = 1 + 100 / 6371;
13
+ /**
14
+ * How many times its real thickness the air is drawn when a page says nothing: 3. The air is a shell 100 km thick on a globe 12,742 km across, a hair's breadth, and at whole-Earth zoom it comes to a line a pixel or two wide (on a phone, thinner still);
15
+ * three times is a ring the eye can find, with the same physics and the same colours. `1` is the true thickness. The page's `air-thickness` attribute chooses.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { AIR_THICKNESS_DEFAULT } from "@johnmorrisdotca/chikyu-earth/realistic";
20
+ * console.log(AIR_THICKNESS_DEFAULT);
21
+ * ```
22
+ */
23
+ export const AIR_THICKNESS_DEFAULT = 3;
24
+ /**
25
+ * The most the air may be thickened: 5, which is as far as the element's box leaves room for (its top is then 1.0785 Earth radii out, inside the 1.08 the box is fitted to).
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { AIR_THICKNESS_MAX } from "@johnmorrisdotca/chikyu-earth/realistic";
30
+ * console.log(AIR_THICKNESS_MAX);
31
+ * ```
32
+ */
33
+ export const AIR_THICKNESS_MAX = 5;
34
+ /**
35
+ * What a page's `air-thickness` attribute means: a number from 1 (the true thickness) to 5, given as it is written; with none, or something that is not a number, `AIR_THICKNESS_DEFAULT`. A number outside the range is brought to its nearest end.
36
+ *
37
+ * @param given - The attribute's value, or `null` when the page has none.
38
+ * @returns How many times its real thickness the air is drawn, between 1 and 5.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { readAirThickness } from "@johnmorrisdotca/chikyu-earth/realistic";
43
+ * console.log(readAirThickness(null), readAirThickness("1"), readAirThickness("9"));
44
+ * ```
45
+ */
46
+ export function readAirThickness(given) {
47
+ if (given === null || given.trim() === "")
48
+ return AIR_THICKNESS_DEFAULT;
49
+ const value = Number(given);
50
+ if (!Number.isFinite(value))
51
+ return AIR_THICKNESS_DEFAULT;
52
+ return Math.min(AIR_THICKNESS_MAX, Math.max(1, value));
53
+ }
54
+ /**
55
+ * Where the air's top is, in Earth radii, when it is drawn `thickness` times its real thickness: 1 plus 100 km times that, over the Earth's 6,371.
56
+ *
57
+ * @param thickness - 1 for the true thickness (the top is then `AIR_TOP`).
58
+ * @returns The radius of the shell's outside, in Earth radii.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { airTop } from "@johnmorrisdotca/chikyu-earth/realistic";
63
+ * console.log(airTop(3).toFixed(4));
64
+ * ```
65
+ */
66
+ export const airTop = (thickness) => 1 + (thickness * 100) / 6371;
13
67
  /**
14
68
  * The two costs of the air. `full` takes 12 samples along the ray toward the camera and 4 toward the Sun at each; `light` (a small or slow device) takes 6 and 2.
15
69
  * Both put their samples where the air is thick (close to the ground, or at the nearest point of a ray that skims it), not evenly, so even the light one has no bands.
@@ -65,6 +119,7 @@ void main() {
65
119
  * the glow toward the Sun, the reddening along the day and night line (the Sun's light has crossed a long, low path) and the thin lit ring seen from the night side looking toward the Sun.
66
120
  * The surface under it is dimmed by what the air takes out of the light (the shader's alpha is what gets through) and what it adds is the colour.
67
121
  * Our own code, from the published single-scattering model (Nishita and others, 1993; O'Neil, GPU Gems 2, chapter 16), no code taken from any project.
122
+ * The air can be drawn thicker than it is (`thick`, a uniform: 1 is the true 100 km, 3 the default of the elements): the shell and both scale heights grow by it and what each unit of length holds shrinks by it, so the same air gives the same colours over a wider glow.
68
123
  * The Sun is in the world's axes (`sunDir`, toward the Sun); `ortho` is 1 when the camera looks down the z axis from far away (the realistic Earth) and 0 for a camera at a place (the space view).
69
124
  *
70
125
  * @param samples - How many samples to take (`AIR_QUALITY.full` or `AIR_QUALITY.light`).
@@ -81,10 +136,17 @@ export const airFrag = (samples) => /* glsl */ `
81
136
  #define N_LIGHT ${samples.light}
82
137
  uniform vec3 sunDir;
83
138
  uniform float ortho;
139
+ uniform float thick;
84
140
  varying vec3 vWorld;
85
- const float TOP = ${AIR_TOP.toFixed(6)};
86
- const float HR = 0.001256;
87
- const float HM = 0.000188;
141
+ const float TOP1 = ${AIR_TOP.toFixed(6)};
142
+ const float HR1 = 0.001256;
143
+ const float HM1 = 0.000188;
144
+ // drawn thick times its real thickness: the shell and both scale heights are that many times larger
145
+ #define TOP (1.0 + (TOP1 - 1.0) * thick)
146
+ #define HR (HR1 * thick)
147
+ #define HM (HM1 * thick)
148
+ // the same amount of air, spread over the taller shell: each unit of length holds that much less of it, so the air looks straight down through is as thin a veil as ever, and only the glow at the limb is wider
149
+ #define DENS (1.0 / thick)
88
150
  const vec3 BETA_R = vec3(36.95, 86.0, 210.9);
89
151
  const float BETA_M = 53.5;
90
152
  const float G = 0.76;
@@ -160,13 +222,13 @@ void main() {
160
222
  if (ahead < 0.0) shade = smoothstep(1.0 - 0.003, 1.0 + 0.003, sqrt(max(dot(p, p) - ahead * ahead, 0.0)));
161
223
  vec2 sun = shade > 0.0 ? column(p, sunDir) : vec2(0.0);
162
224
  vec2 path = depth + 0.5 * here;
163
- vec3 gone = exp(-(BETA_R * (path.x + sun.x) + BETA_M * 1.1 * (path.y + sun.y)));
225
+ vec3 gone = exp(-DENS * (BETA_R * (path.x + sun.x) + BETA_M * 1.1 * (path.y + sun.y)));
164
226
  sumR += gone * here.x * shade;
165
227
  sumM += gone * here.y * shade;
166
228
  depth += here;
167
229
  }
168
- vec3 colour = SUN * (sumR * BETA_R * phaseR + sumM * BETA_M * phaseM);
169
- vec3 through = exp(-(BETA_R * depth.x + BETA_M * 1.1 * depth.y));
230
+ vec3 colour = SUN * DENS * (sumR * BETA_R * phaseR + sumM * BETA_M * phaseM);
231
+ vec3 through = exp(-DENS * (BETA_R * depth.x + BETA_M * 1.1 * depth.y));
170
232
  // the colour is premultiplied: what is added, and how much of what is behind it gets through
171
233
  // a steep look at the ground through the air has only a thin veil over it; the haze gathers toward the limb, where the path through the air is long
172
234
  colour *= onGround ? 0.1 + 0.9 * smoothstep(0.02, 0.16, tEnd) : 1.0;
@@ -60,6 +60,8 @@ export interface EarthModel {
60
60
  light: LightMode;
61
61
  /** How the camera is held (see `CameraMode`). */
62
62
  camera: CameraMode;
63
+ /** How many times its real thickness the air is drawn, 1 to 5 (`AIR_THICKNESS_DEFAULT` until the element says otherwise); read at every draw. */
64
+ airThickness: number;
63
65
  /** How fast the cloud picture is made to move eastward against the ground, degrees an hour: 0 (the default) keeps the clouds where the picture has them. The picture is one snapshot, not a forecast; a drift is only for life. */
64
66
  cloudDrift: number;
65
67
  /** For the `space` camera: the Earth's turn against the stars (degrees) when the camera was set; null until the next draw sets it. */
@@ -1,5 +1,5 @@
1
1
  import { HOME_VIEW, lookAt } from "../view.js";
2
- import { AIR_QUALITY, AIR_TOP, AIR_VERT, airFrag } from "./air.js";
2
+ import { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_VERT, airFrag, airTop } from "./air.js";
3
3
  import { CLOUD_FRAG, SURFACE_FRAG, SURFACE_VERT } from "./shaders.js";
4
4
  import { greenwichSidereal, subsolarPoint, unitVector } from "./sun.js";
5
5
  import { createSatelliteLayer, newSatelliteState } from "../space/satellite-layer.js";
@@ -28,6 +28,7 @@ export const newModel = () => ({
28
28
  lights: true,
29
29
  light: "sun",
30
30
  camera: "space",
31
+ airThickness: AIR_THICKNESS_DEFAULT,
31
32
  cloudDrift: 0,
32
33
  cameraSpin: null,
33
34
  speed: 1,
@@ -151,7 +152,7 @@ export function createEarthItem(model, deps) {
151
152
  const atmosphere = new three.ShaderMaterial({
152
153
  vertexShader: AIR_VERT,
153
154
  fragmentShader: airFrag(AIR_QUALITY[deps.air?.() ?? "full"]),
154
- uniforms: { sunDir, ortho: { value: 1 } },
155
+ uniforms: { sunDir, ortho: { value: 1 }, thick: { value: model.airThickness } },
155
156
  transparent: true,
156
157
  premultipliedAlpha: true,
157
158
  depthWrite: false,
@@ -165,7 +166,7 @@ export function createEarthItem(model, deps) {
165
166
  clouds.renderOrder = 2;
166
167
  turned.add(earth, clouds);
167
168
  const glow = new three.Mesh(grid, atmosphere);
168
- glow.scale.setScalar(AIR_TOP);
169
+ glow.scale.setScalar(airTop(model.airThickness));
169
170
  glow.renderOrder = 3;
170
171
  glow.frustumCulled = false;
171
172
  const scene = new three.Scene();
@@ -201,6 +202,8 @@ export function createEarthItem(model, deps) {
201
202
  sunDir.value.set(0, 0, 1);
202
203
  cloudShift.value = -(((model.time / 3_600_000) * model.cloudDrift) % 360) / 360;
203
204
  clouds.visible = model.clouds;
205
+ atmosphere.uniforms["thick"].value = model.airThickness;
206
+ glow.scale.setScalar(airTop(model.airThickness));
204
207
  surface.uniforms["lights"].value = model.lights && model.light !== "lit" ? 1 : 0;
205
208
  surface.uniforms["boost"].value = model.light === "boost" ? 1 : 0;
206
209
  const radius = discRadius(size.width, size.height, view.zoom);
@@ -79,6 +79,7 @@ export declare const readTime: (value: string | null) => number | "now";
79
79
  * where they fall, their height and the showers' dates are real (`@johnmorrisdotca/chikyu-earth/meteors`). They run while the clock runs, at any speed, and not
80
80
  * at all while it is held, out of sight, in a hidden tab, or for a reader who prefers reduced motion until the page sets a `speed` (a Play). `chikyu-meteors`
81
81
  * is sent when the strongest active shower changes, with `detail: { shower, zhr }` (`shower` is `null` when none is active).
82
+ * `meteors-strength` (0 to 1, the property `meteorsStrength`; 1 when the page says nothing) makes them subtler: fewer streaks and fainter ones, none at 0, and nothing that is real changes.
82
83
  *
83
84
  * @example
84
85
  * ```ts no-run
@@ -103,11 +104,24 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
103
104
  connectedCallback(): void;
104
105
  disconnectedCallback(): void;
105
106
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
107
+ /**
108
+ * How many times its real thickness the air is drawn, from 1 (the true thickness) to 5 (the attribute `air-thickness`; 3 when the page says nothing). The shell, and the heights over which the air thins, are that many times larger, and the
109
+ * air's own light is the same, so a ring that is a hair's breadth at whole-Earth zoom can be seen. While it is above 1 the element says so in a line under the picture (`air-label="off"` takes the line away, for a page that says it itself).
110
+ */
111
+ get airThickness(): number;
112
+ set airThickness(value: number);
106
113
  /**
107
114
  * Meteors seen from space, on or off (the attribute `meteors`): see the class's description. Off by default, and nothing of theirs is made until they are first switched on.
108
115
  */
109
116
  get meteors(): boolean;
110
117
  set meteors(value: boolean);
118
+ /**
119
+ * How strongly the meteors are drawn, from 0 to 1 (the attribute `meteors-strength`; 1, the full look, when the page says nothing): it scales how bright each streak is and how many are drawn, so 0.3 is
120
+ * fewer and fainter and 0 draws none. It changes nothing that is real: the rates, the showers and `chikyu-meteors` are the same at every strength, and the line under the picture still says the streaks are an illustration.
121
+ * A number outside the range is brought to its nearest end; setting the property writes the attribute.
122
+ */
123
+ get meteorsStrength(): number;
124
+ set meteorsStrength(value: number);
111
125
  /** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
112
126
  get controller(): ViewController | undefined;
113
127
  /** Where the finer map tiles are served from (a folder with `manifest.json`), or `null` for none; the attribute `tiles`. The Earth loads only the tiles in view, over its own pictures. */
@@ -164,6 +178,7 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
164
178
  /** The meteors: whether they are on, the streaks alive now and started so far, the streaks a second being drawn, and the strongest active shower's code and rate. */
165
179
  meteors: {
166
180
  on: boolean;
181
+ strength: number;
167
182
  alive: number;
168
183
  spawned: number;
169
184
  perSecond: number;
@@ -3,16 +3,18 @@
3
3
  // changes, at most 30 times a second, and nothing at all while it is out of sight or the tab is hidden.
4
4
  import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
5
5
  import { adoptStyles } from "../adopt.js";
6
- import { airFor } from "./air.js";
6
+ import { airFor, readAirThickness } from "./air.js";
7
+ import { NOTES_STYLE, setAirNote } from "./air-note.js";
7
8
  import { cameraCentre, createEarthItem, discRadius, lookAt, newModel } from "./earth.js";
8
9
  import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
9
10
  import { MAX_ORBIT_GROUP } from "../space/satellite-layer.js";
11
+ import { readMeteorStrength } from "../meteors/strength.js";
10
12
  import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
11
13
  import { createGate, frameCap } from "./gate.js";
12
14
  import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
13
15
  export { setSharedRenderer, setThreeLoader };
14
16
  import { MAX_TEXTURE, TIERS } from "./tiers.js";
15
- const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#overlay{position:absolute;inset:0}#overlay{pointer-events:none}" + METEOR_NOTE_STYLE;
17
+ const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#overlay{position:absolute;inset:0}#overlay{pointer-events:none}" + METEOR_NOTE_STYLE + NOTES_STYLE;
16
18
  const RAD = Math.PI / 180;
17
19
  /** The Sun and the clouds are re-placed this often at real time: 15 degrees an hour is 0.25 degree a minute. */
18
20
  const LIVE_TICK_MS = 60_000;
@@ -103,6 +105,7 @@ export const readTime = (value) => {
103
105
  * where they fall, their height and the showers' dates are real (`@johnmorrisdotca/chikyu-earth/meteors`). They run while the clock runs, at any speed, and not
104
106
  * at all while it is held, out of sight, in a hidden tab, or for a reader who prefers reduced motion until the page sets a `speed` (a Play). `chikyu-meteors`
105
107
  * is sent when the strongest active shower changes, with `detail: { shower, zhr }` (`shower` is `null` when none is active).
108
+ * `meteors-strength` (0 to 1, the property `meteorsStrength`; 1 when the page says nothing) makes them subtler: fewer streaks and fainter ones, none at 0, and nothing that is real changes.
106
109
  *
107
110
  * @example
108
111
  * ```ts no-run
@@ -122,7 +125,7 @@ export const readTime = (value) => {
122
125
  * ```
123
126
  */
124
127
  export class ChikyuEarthRealistic extends HTMLElement {
125
- static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "camera", "immersive", "meteors", "meteors-label", "lang"];
128
+ static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", "air-thickness", "air-label", "lang"];
126
129
  #model = newModel();
127
130
  #mode = "now";
128
131
  #view;
@@ -147,6 +150,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
147
150
  /** The page has set a `speed` since the element came into the page: for a reader who prefers reduced motion, that is the Play that lets meteors start. */
148
151
  #played = false;
149
152
  #note;
153
+ #airNote;
150
154
  #onContext = (state) => {
151
155
  if (state === "unavailable")
152
156
  this.#fail("WebGL is not available");
@@ -165,22 +169,26 @@ export class ChikyuEarthRealistic extends HTMLElement {
165
169
  this.#model.light = readLight(this.getAttribute("light"));
166
170
  this.#model.camera = readCamera(this.getAttribute("camera"));
167
171
  this.#model.cloudDrift = readDrift(this.getAttribute("cloud-drift"));
172
+ this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
168
173
  this.#model.speed = this.speed;
169
174
  if (!this.hasAttribute("role"))
170
175
  this.setAttribute("role", "img");
171
176
  if (!this.hasAttribute("aria-label"))
172
177
  this.setAttribute("aria-label", "The Earth from space, with its sunlit and dark sides");
173
178
  const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
174
- root.innerHTML = `<div id="stage"></div><div id="overlay"></div><p id="meteor-note" hidden></p>`;
179
+ root.innerHTML = `<div id="stage"></div><div id="overlay"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p></div>`;
175
180
  adoptStyles(root, STYLE, this.nonce);
176
181
  this.#stage = root.getElementById("stage");
177
182
  this.#overlay = root.getElementById("overlay");
178
183
  this.#note = root.getElementById("meteor-note");
184
+ this.#airNote = root.getElementById("air-note");
179
185
  this.#played = false;
180
186
  this.#model.meteors.on = this.#meteorsAsked();
187
+ this.#model.meteors.strength = readMeteorStrength(this.getAttribute("meteors-strength"));
181
188
  this.#model.meteors.running = () => this.speed !== 0 && document.visibilityState !== "hidden" && (this.#played || !prefersLessMotion());
182
189
  this.#model.meteors.onShower = (shower, zhr) => this.dispatchEvent(new CustomEvent("chikyu-meteors", { detail: { shower, zhr } }));
183
190
  this.#meteorNote();
191
+ setAirNote(this.#airNote, this, this.#model.airThickness);
184
192
  this.#stage.addEventListener("webglcontextlost", this.#lost, true);
185
193
  this.#stage.addEventListener("webglcontextrestored", this.#restored, true);
186
194
  const nav = navigator;
@@ -291,8 +299,18 @@ export class ChikyuEarthRealistic extends HTMLElement {
291
299
  }
292
300
  else if (name === "meteors")
293
301
  this.meteors = this.#meteorsAsked();
302
+ else if (name === "meteors-strength") {
303
+ this.#model.meteors.strength = readMeteorStrength(value);
304
+ this.#gate?.soon();
305
+ }
306
+ else if (name === "air-thickness") {
307
+ this.#model.airThickness = readAirThickness(value);
308
+ this.#gate?.soon();
309
+ }
294
310
  else if (name === "meteors-label" || name === "lang")
295
311
  this.#meteorNote();
312
+ if (name === "air-thickness" || name === "air-label" || name === "lang")
313
+ setAirNote(this.#airNote, this, this.#model.airThickness);
296
314
  }
297
315
  #meteorsAsked() {
298
316
  return this.hasAttribute("meteors") && this.getAttribute("meteors") !== "off";
@@ -301,6 +319,16 @@ export class ChikyuEarthRealistic extends HTMLElement {
301
319
  #meteorNote() {
302
320
  setMeteorNote(this.#note, this, this.#model.meteors.on);
303
321
  }
322
+ /**
323
+ * How many times its real thickness the air is drawn, from 1 (the true thickness) to 5 (the attribute `air-thickness`; 3 when the page says nothing). The shell, and the heights over which the air thins, are that many times larger, and the
324
+ * air's own light is the same, so a ring that is a hair's breadth at whole-Earth zoom can be seen. While it is above 1 the element says so in a line under the picture (`air-label="off"` takes the line away, for a page that says it itself).
325
+ */
326
+ get airThickness() {
327
+ return this.#model.airThickness;
328
+ }
329
+ set airThickness(value) {
330
+ this.setAttribute("air-thickness", String(value));
331
+ }
304
332
  /**
305
333
  * Meteors seen from space, on or off (the attribute `meteors`): see the class's description. Off by default, and nothing of theirs is made until they are first switched on.
306
334
  */
@@ -319,6 +347,17 @@ export class ChikyuEarthRealistic extends HTMLElement {
319
347
  this.#meteorNote();
320
348
  this.#gate?.soon();
321
349
  }
350
+ /**
351
+ * How strongly the meteors are drawn, from 0 to 1 (the attribute `meteors-strength`; 1, the full look, when the page says nothing): it scales how bright each streak is and how many are drawn, so 0.3 is
352
+ * fewer and fainter and 0 draws none. It changes nothing that is real: the rates, the showers and `chikyu-meteors` are the same at every strength, and the line under the picture still says the streaks are an illustration.
353
+ * A number outside the range is brought to its nearest end; setting the property writes the attribute.
354
+ */
355
+ get meteorsStrength() {
356
+ return this.#model.meteors.strength;
357
+ }
358
+ set meteorsStrength(value) {
359
+ this.setAttribute("meteors-strength", String(value));
360
+ }
322
361
  /** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
323
362
  get controller() {
324
363
  return this.#hands?.controller;
@@ -452,7 +491,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
452
491
  contexts: stats?.contexts ?? 0,
453
492
  canvas: stats?.canvas ?? { width: 0, height: 0, pixels: 0 },
454
493
  assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
455
- meteors: { on: this.#model.meteors.on, ...this.#model.meteors.drawn },
494
+ meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
456
495
  };
457
496
  }
458
497
  /**
@@ -5,4 +5,5 @@ export { lookAt, discRadius, ATMOSPHERE_OUTER, cameraCentre, type CameraMode, ty
5
5
  export type { ThreeParts } from "./earth.ts";
6
6
  export { TEXEL_SLACK, coveringTile, parseManifest, pointOnEarth, tileColumns, tileLevel, tileRect, tileRows, tilesInView, type TileCamera, type TileId, type TileLayer, type VisibleTile } from "./tiles.ts";
7
7
  export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.ts";
8
- export { AIR_QUALITY, AIR_TOP, AIR_VERT, airFor, airFrag, type AirSamples } from "./air.ts";
8
+ export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VERT, airFor, airFrag, airTop, readAirThickness, type AirSamples } from "./air.ts";
9
+ export { AIR_NOTE } from "./air-note.ts";
@@ -6,4 +6,5 @@ export { createGate, frameCap } from "./gate.js";
6
6
  export { lookAt, discRadius, ATMOSPHERE_OUTER, cameraCentre } from "./earth.js";
7
7
  export { TEXEL_SLACK, coveringTile, parseManifest, pointOnEarth, tileColumns, tileLevel, tileRect, tileRows, tilesInView } from "./tiles.js";
8
8
  export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.js";
9
- export { AIR_QUALITY, AIR_TOP, AIR_VERT, airFor, airFrag } from "./air.js";
9
+ export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VERT, airFor, airFrag, airTop, readAirThickness } from "./air.js";
10
+ export { AIR_NOTE } from "./air-note.js";
@@ -155,6 +155,19 @@ export declare class ChikyuSpace extends HTMLElement {
155
155
  */
156
156
  get meteors(): boolean;
157
157
  set meteors(value: boolean);
158
+ /**
159
+ * How strongly the meteors are drawn, from 0 to 1 (the attribute `meteors-strength`; 1, the full look, when the page says nothing): it scales how bright each streak is and how many are drawn, so 0.3 is
160
+ * fewer and fainter and 0 draws none. It changes nothing that is real: the rates, the showers and `chikyu-meteors` are the same at every strength, and the line under the picture still says the streaks are an illustration.
161
+ * A number outside the range is brought to its nearest end; setting the property writes the attribute.
162
+ */
163
+ get meteorsStrength(): number;
164
+ set meteorsStrength(value: number);
165
+ /**
166
+ * How many times its real thickness the air is drawn, from 1 (the true thickness) to 5 (the attribute `air-thickness`; 3 when the page says nothing): see `<chikyu-earth-realistic>`. While it is above 1 the element says so in a line
167
+ * under the picture (`air-label="off"` takes the line away, for a page that says it itself).
168
+ */
169
+ get airThickness(): number;
170
+ set airThickness(value: number);
158
171
  get centre(): GeoPoint;
159
172
  set centre(value: GeoPoint);
160
173
  /**
@@ -295,6 +308,7 @@ export declare class ChikyuSpace extends HTMLElement {
295
308
  /** The meteors: whether they are on, the streaks alive now and started so far, the streaks a second being drawn, and the strongest active shower's code and rate. */
296
309
  meteors: {
297
310
  on: boolean;
311
+ strength: number;
298
312
  alive: number;
299
313
  spawned: number;
300
314
  perSecond: number;
@@ -1,8 +1,10 @@
1
1
  import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
2
  import { adoptStyles } from "../adopt.js";
3
- import { airFor } from "../realistic/air.js";
3
+ import { airFor, readAirThickness } from "../realistic/air.js";
4
4
  import { createGate, frameCap } from "../realistic/gate.js";
5
5
  import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
6
+ import { NOTES_STYLE, setAirNote } from "../realistic/air-note.js";
7
+ import { readMeteorStrength } from "../meteors/strength.js";
6
8
  import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
7
9
  import { MAX_TEXTURE } from "../realistic/tiers.js";
8
10
  import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
@@ -72,7 +74,7 @@ const readTime = (value) => {
72
74
  const ms = Date.parse(value);
73
75
  return Number.isFinite(ms) ? ms : "now";
74
76
  };
75
- const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-sat{position:absolute;left:0;top:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-sat[hidden]{display:none}${METEOR_NOTE_STYLE}`;
77
+ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-sat{position:absolute;left:0;top:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-sat[hidden]{display:none}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
76
78
  /**
77
79
  * The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
78
80
  *
@@ -98,7 +100,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
98
100
  * ```
99
101
  */
100
102
  export class ChikyuSpace extends HTMLElement {
101
- static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "lang"];
103
+ static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", "air-thickness", "air-label", "lang"];
102
104
  #model = newSpaceModel();
103
105
  #mode = "now";
104
106
  #speed = 1;
@@ -106,6 +108,7 @@ export class ChikyuSpace extends HTMLElement {
106
108
  /** The page has set a `speed` since the element came into the page: for a reader who prefers reduced motion, that is the Play that lets meteors start. */
107
109
  #played = false;
108
110
  #note;
111
+ #airNote;
109
112
  #gate;
110
113
  #taken;
111
114
  #stage;
@@ -148,13 +151,17 @@ export class ChikyuSpace extends HTMLElement {
148
151
  if (!this.hasAttribute("aria-label"))
149
152
  this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
150
153
  const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
151
- root.innerHTML = `<div id="stage"></div><div id="labels" aria-hidden="true"></div><p id="meteor-note" hidden></p>`;
154
+ root.innerHTML = `<div id="stage"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p></div>`;
152
155
  adoptStyles(root, STYLE, this.nonce);
153
156
  this.#stage = root.getElementById("stage");
154
157
  this.#labelBox = root.getElementById("labels");
155
158
  this.#note = root.getElementById("meteor-note");
159
+ this.#airNote = root.getElementById("air-note");
160
+ this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
161
+ setAirNote(this.#airNote, this, this.#model.airThickness);
156
162
  this.#played = false;
157
163
  this.#model.meteors.on = this.#meteorsAsked();
164
+ this.#model.meteors.strength = readMeteorStrength(this.getAttribute("meteors-strength"));
158
165
  this.#model.meteors.running = () => this.#speed !== 0 && document.visibilityState !== "hidden" && (this.#played || !prefersLessMotion());
159
166
  this.#model.meteors.onShower = (shower, zhr) => this.dispatchEvent(new CustomEvent("chikyu-meteors", { detail: { shower, zhr } }));
160
167
  setMeteorNote(this.#note, this, this.#model.meteors.on);
@@ -248,8 +255,18 @@ export class ChikyuSpace extends HTMLElement {
248
255
  this.earthY = readNumber(value, 0.5, -2, 3);
249
256
  else if (name === "meteors")
250
257
  this.meteors = this.#meteorsAsked();
258
+ else if (name === "meteors-strength") {
259
+ this.#model.meteors.strength = readMeteorStrength(value);
260
+ this.#gate?.request();
261
+ }
262
+ else if (name === "air-thickness") {
263
+ this.#model.airThickness = readAirThickness(value);
264
+ this.#gate?.request();
265
+ }
251
266
  else if (name === "meteors-label" || name === "lang")
252
267
  setMeteorNote(this.#note, this, this.#model.meteors.on);
268
+ if (name === "air-thickness" || name === "air-label" || name === "lang")
269
+ setAirNote(this.#airNote, this, this.#model.airThickness);
253
270
  }
254
271
  #meteorsAsked() {
255
272
  return this.hasAttribute("meteors") && this.getAttribute("meteors") !== "off";
@@ -275,6 +292,27 @@ export class ChikyuSpace extends HTMLElement {
275
292
  setMeteorNote(this.#note, this, value);
276
293
  this.#gate?.request();
277
294
  }
295
+ /**
296
+ * How strongly the meteors are drawn, from 0 to 1 (the attribute `meteors-strength`; 1, the full look, when the page says nothing): it scales how bright each streak is and how many are drawn, so 0.3 is
297
+ * fewer and fainter and 0 draws none. It changes nothing that is real: the rates, the showers and `chikyu-meteors` are the same at every strength, and the line under the picture still says the streaks are an illustration.
298
+ * A number outside the range is brought to its nearest end; setting the property writes the attribute.
299
+ */
300
+ get meteorsStrength() {
301
+ return this.#model.meteors.strength;
302
+ }
303
+ set meteorsStrength(value) {
304
+ this.setAttribute("meteors-strength", String(value));
305
+ }
306
+ /**
307
+ * How many times its real thickness the air is drawn, from 1 (the true thickness) to 5 (the attribute `air-thickness`; 3 when the page says nothing): see `<chikyu-earth-realistic>`. While it is above 1 the element says so in a line
308
+ * under the picture (`air-label="off"` takes the line away, for a page that says it itself).
309
+ */
310
+ get airThickness() {
311
+ return this.#model.airThickness;
312
+ }
313
+ set airThickness(value) {
314
+ this.setAttribute("air-thickness", String(value));
315
+ }
278
316
  get centre() {
279
317
  return { ...this.#model.centre };
280
318
  }
@@ -622,7 +660,7 @@ export class ChikyuSpace extends HTMLElement {
622
660
  ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
623
661
  camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], fov: this.#model.pose.fov },
624
662
  bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons },
625
- meteors: { on: this.#model.meteors.on, ...this.#model.meteors.drawn },
663
+ meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
626
664
  };
627
665
  }
628
666
  #satelliteStats() {
@@ -109,6 +109,8 @@ export interface SpaceModel {
109
109
  };
110
110
  /** Which way the camera is held (see `CameraMode`). */
111
111
  camera: CameraMode;
112
+ /** How many times its real thickness the air is drawn, 1 to 5 (`AIR_THICKNESS_DEFAULT` until the element says otherwise); read at every draw. */
113
+ airThickness: number;
112
114
  /** Degrees an hour the cloud picture is made to move eastward against the ground: 0, the default (it is one snapshot, not a forecast). */
113
115
  cloudDrift: number;
114
116
  /** For the `space` camera: the Earth's turn against the stars (degrees) at the moment the camera was set, so it stays in the stars while the Earth turns beneath; null until the next draw sets it. */
@@ -1,4 +1,4 @@
1
- import { AIR_QUALITY, AIR_TOP, AIR_VERT, airFrag } from "../realistic/air.js";
1
+ import { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_VERT, airFrag, airTop } from "../realistic/air.js";
2
2
  import { sphere } from "../realistic/earth.js";
3
3
  import { BODY_FRAG, CLOUD_FRAG, GLOW_FRAG, GLOW_VERT, SURFACE_FRAG, SURFACE_VERT } from "../realistic/shaders.js";
4
4
  import { createTextureSet } from "../realistic/textures.js";
@@ -57,6 +57,7 @@ export const newSpaceModel = () => ({
57
57
  view: { yaw: 0, tilt: 0, zoom: 1 },
58
58
  centre: { lon: 0, lat: 0 },
59
59
  camera: "space",
60
+ airThickness: AIR_THICKNESS_DEFAULT,
60
61
  cloudDrift: 0,
61
62
  cameraSpin: null,
62
63
  earth: { size: DEFAULT_EARTH_SIZE, x: 0.5, y: 0.5 },
@@ -180,7 +181,7 @@ export function createSpaceItem(model, deps) {
180
181
  const atmosphereMaterial = new three.ShaderMaterial({
181
182
  vertexShader: AIR_VERT,
182
183
  fragmentShader: airFrag(AIR_QUALITY[deps.air?.() ?? "full"]),
183
- uniforms: { sunDir: sunEarth, ortho: { value: 0 } },
184
+ uniforms: { sunDir: sunEarth, ortho: { value: 0 }, thick: { value: model.airThickness } },
184
185
  transparent: true,
185
186
  premultipliedAlpha: true,
186
187
  depthWrite: false,
@@ -190,7 +191,7 @@ export function createSpaceItem(model, deps) {
190
191
  clouds.scale.setScalar(1.006);
191
192
  clouds.renderOrder = 3;
192
193
  const glow = new three.Mesh(grid, atmosphereMaterial);
193
- glow.scale.setScalar(AIR_TOP);
194
+ glow.scale.setScalar(airTop(model.airThickness));
194
195
  glow.renderOrder = 4;
195
196
  glow.frustumCulled = false;
196
197
  const moonSun = { value: new three.Vector3(1, 0, 0) };
@@ -310,6 +311,8 @@ export function createSpaceItem(model, deps) {
310
311
  sunLocal.value.set(toSun[0] * Math.cos(back) + toSun[2] * Math.sin(back), toSun[1], -toSun[0] * Math.sin(back) + toSun[2] * Math.cos(back));
311
312
  }
312
313
  cloudShift.value = -(((model.time / 3_600_000) * model.cloudDrift) % 360) / 360;
314
+ atmosphereMaterial.uniforms["thick"].value = model.airThickness;
315
+ glow.scale.setScalar(airTop(model.airThickness));
313
316
  earthMaterial.uniforms["lights"].value = model.light === "lit" ? 0 : 1;
314
317
  earthMaterial.uniforms["boost"].value = model.light === "boost" ? 1 : 0;
315
318
  // the Moon, with its near side to the Earth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on where you are, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
5
5
  "keywords": [
6
6
  "earth",