@johnmorrisdotca/chikyu-earth 0.28.0 → 0.29.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 +4 -0
- package/README.md +1 -1
- package/dist/realistic/air-note.d.ts +19 -0
- package/dist/realistic/air-note.js +29 -0
- package/dist/realistic/air.d.ts +48 -0
- package/dist/realistic/air.js +68 -6
- package/dist/realistic/earth.d.ts +2 -0
- package/dist/realistic/earth.js +6 -3
- package/dist/realistic/element.d.ts +6 -0
- package/dist/realistic/element.js +25 -4
- package/dist/realistic/index.d.ts +2 -1
- package/dist/realistic/index.js +2 -1
- package/dist/space/element.d.ts +6 -0
- package/dist/space/element.js +25 -4
- package/dist/space/scene.d.ts +2 -0
- package/dist/space/scene.js +6 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.29.0 - 2026-11-11
|
|
6
|
+
|
|
7
|
+
- **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`.
|
|
8
|
+
|
|
5
9
|
## 0.28.0 - 2026-11-11
|
|
6
10
|
|
|
7
11
|
- **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
|
@@ -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.
|
|
492
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.29.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
|
|
|
@@ -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
|
+
}
|
package/dist/realistic/air.d.ts
CHANGED
|
@@ -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`).
|
package/dist/realistic/air.js
CHANGED
|
@@ -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
|
|
86
|
-
const float
|
|
87
|
-
const float
|
|
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. */
|
package/dist/realistic/earth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HOME_VIEW, lookAt } from "../view.js";
|
|
2
|
-
import { AIR_QUALITY,
|
|
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(
|
|
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);
|
|
@@ -103,6 +103,12 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
103
103
|
connectedCallback(): void;
|
|
104
104
|
disconnectedCallback(): void;
|
|
105
105
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
106
|
+
/**
|
|
107
|
+
* 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
|
|
108
|
+
* 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).
|
|
109
|
+
*/
|
|
110
|
+
get airThickness(): number;
|
|
111
|
+
set airThickness(value: number);
|
|
106
112
|
/**
|
|
107
113
|
* 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
114
|
*/
|
|
@@ -3,7 +3,8 @@
|
|
|
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";
|
|
@@ -12,7 +13,7 @@ import { createGate, frameCap } from "./gate.js";
|
|
|
12
13
|
import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
|
|
13
14
|
export { setSharedRenderer, setThreeLoader };
|
|
14
15
|
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;
|
|
16
|
+
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
17
|
const RAD = Math.PI / 180;
|
|
17
18
|
/** The Sun and the clouds are re-placed this often at real time: 15 degrees an hour is 0.25 degree a minute. */
|
|
18
19
|
const LIVE_TICK_MS = 60_000;
|
|
@@ -122,7 +123,7 @@ export const readTime = (value) => {
|
|
|
122
123
|
* ```
|
|
123
124
|
*/
|
|
124
125
|
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"];
|
|
126
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "camera", "immersive", "meteors", "meteors-label", "air-thickness", "air-label", "lang"];
|
|
126
127
|
#model = newModel();
|
|
127
128
|
#mode = "now";
|
|
128
129
|
#view;
|
|
@@ -147,6 +148,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
147
148
|
/** 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
149
|
#played = false;
|
|
149
150
|
#note;
|
|
151
|
+
#airNote;
|
|
150
152
|
#onContext = (state) => {
|
|
151
153
|
if (state === "unavailable")
|
|
152
154
|
this.#fail("WebGL is not available");
|
|
@@ -165,22 +167,25 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
165
167
|
this.#model.light = readLight(this.getAttribute("light"));
|
|
166
168
|
this.#model.camera = readCamera(this.getAttribute("camera"));
|
|
167
169
|
this.#model.cloudDrift = readDrift(this.getAttribute("cloud-drift"));
|
|
170
|
+
this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
|
|
168
171
|
this.#model.speed = this.speed;
|
|
169
172
|
if (!this.hasAttribute("role"))
|
|
170
173
|
this.setAttribute("role", "img");
|
|
171
174
|
if (!this.hasAttribute("aria-label"))
|
|
172
175
|
this.setAttribute("aria-label", "The Earth from space, with its sunlit and dark sides");
|
|
173
176
|
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>`;
|
|
177
|
+
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
178
|
adoptStyles(root, STYLE, this.nonce);
|
|
176
179
|
this.#stage = root.getElementById("stage");
|
|
177
180
|
this.#overlay = root.getElementById("overlay");
|
|
178
181
|
this.#note = root.getElementById("meteor-note");
|
|
182
|
+
this.#airNote = root.getElementById("air-note");
|
|
179
183
|
this.#played = false;
|
|
180
184
|
this.#model.meteors.on = this.#meteorsAsked();
|
|
181
185
|
this.#model.meteors.running = () => this.speed !== 0 && document.visibilityState !== "hidden" && (this.#played || !prefersLessMotion());
|
|
182
186
|
this.#model.meteors.onShower = (shower, zhr) => this.dispatchEvent(new CustomEvent("chikyu-meteors", { detail: { shower, zhr } }));
|
|
183
187
|
this.#meteorNote();
|
|
188
|
+
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
184
189
|
this.#stage.addEventListener("webglcontextlost", this.#lost, true);
|
|
185
190
|
this.#stage.addEventListener("webglcontextrestored", this.#restored, true);
|
|
186
191
|
const nav = navigator;
|
|
@@ -291,8 +296,14 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
291
296
|
}
|
|
292
297
|
else if (name === "meteors")
|
|
293
298
|
this.meteors = this.#meteorsAsked();
|
|
299
|
+
else if (name === "air-thickness") {
|
|
300
|
+
this.#model.airThickness = readAirThickness(value);
|
|
301
|
+
this.#gate?.soon();
|
|
302
|
+
}
|
|
294
303
|
else if (name === "meteors-label" || name === "lang")
|
|
295
304
|
this.#meteorNote();
|
|
305
|
+
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
306
|
+
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
296
307
|
}
|
|
297
308
|
#meteorsAsked() {
|
|
298
309
|
return this.hasAttribute("meteors") && this.getAttribute("meteors") !== "off";
|
|
@@ -301,6 +312,16 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
301
312
|
#meteorNote() {
|
|
302
313
|
setMeteorNote(this.#note, this, this.#model.meteors.on);
|
|
303
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* 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
|
|
317
|
+
* 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).
|
|
318
|
+
*/
|
|
319
|
+
get airThickness() {
|
|
320
|
+
return this.#model.airThickness;
|
|
321
|
+
}
|
|
322
|
+
set airThickness(value) {
|
|
323
|
+
this.setAttribute("air-thickness", String(value));
|
|
324
|
+
}
|
|
304
325
|
/**
|
|
305
326
|
* 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
327
|
*/
|
|
@@ -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";
|
package/dist/realistic/index.js
CHANGED
|
@@ -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";
|
package/dist/space/element.d.ts
CHANGED
|
@@ -155,6 +155,12 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
155
155
|
*/
|
|
156
156
|
get meteors(): boolean;
|
|
157
157
|
set meteors(value: boolean);
|
|
158
|
+
/**
|
|
159
|
+
* 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
|
|
160
|
+
* under the picture (`air-label="off"` takes the line away, for a page that says it itself).
|
|
161
|
+
*/
|
|
162
|
+
get airThickness(): number;
|
|
163
|
+
set airThickness(value: number);
|
|
158
164
|
get centre(): GeoPoint;
|
|
159
165
|
set centre(value: GeoPoint);
|
|
160
166
|
/**
|
package/dist/space/element.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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";
|
|
6
7
|
import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
|
|
7
8
|
import { MAX_TEXTURE } from "../realistic/tiers.js";
|
|
8
9
|
import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
|
|
@@ -72,7 +73,7 @@ const readTime = (value) => {
|
|
|
72
73
|
const ms = Date.parse(value);
|
|
73
74
|
return Number.isFinite(ms) ? ms : "now";
|
|
74
75
|
};
|
|
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}`;
|
|
76
|
+
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
77
|
/**
|
|
77
78
|
* 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
79
|
*
|
|
@@ -98,7 +99,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
98
99
|
* ```
|
|
99
100
|
*/
|
|
100
101
|
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"];
|
|
102
|
+
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "air-thickness", "air-label", "lang"];
|
|
102
103
|
#model = newSpaceModel();
|
|
103
104
|
#mode = "now";
|
|
104
105
|
#speed = 1;
|
|
@@ -106,6 +107,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
106
107
|
/** 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
108
|
#played = false;
|
|
108
109
|
#note;
|
|
110
|
+
#airNote;
|
|
109
111
|
#gate;
|
|
110
112
|
#taken;
|
|
111
113
|
#stage;
|
|
@@ -148,11 +150,14 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
148
150
|
if (!this.hasAttribute("aria-label"))
|
|
149
151
|
this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
|
|
150
152
|
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>`;
|
|
153
|
+
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
154
|
adoptStyles(root, STYLE, this.nonce);
|
|
153
155
|
this.#stage = root.getElementById("stage");
|
|
154
156
|
this.#labelBox = root.getElementById("labels");
|
|
155
157
|
this.#note = root.getElementById("meteor-note");
|
|
158
|
+
this.#airNote = root.getElementById("air-note");
|
|
159
|
+
this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
|
|
160
|
+
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
156
161
|
this.#played = false;
|
|
157
162
|
this.#model.meteors.on = this.#meteorsAsked();
|
|
158
163
|
this.#model.meteors.running = () => this.#speed !== 0 && document.visibilityState !== "hidden" && (this.#played || !prefersLessMotion());
|
|
@@ -248,8 +253,14 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
248
253
|
this.earthY = readNumber(value, 0.5, -2, 3);
|
|
249
254
|
else if (name === "meteors")
|
|
250
255
|
this.meteors = this.#meteorsAsked();
|
|
256
|
+
else if (name === "air-thickness") {
|
|
257
|
+
this.#model.airThickness = readAirThickness(value);
|
|
258
|
+
this.#gate?.request();
|
|
259
|
+
}
|
|
251
260
|
else if (name === "meteors-label" || name === "lang")
|
|
252
261
|
setMeteorNote(this.#note, this, this.#model.meteors.on);
|
|
262
|
+
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
263
|
+
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
253
264
|
}
|
|
254
265
|
#meteorsAsked() {
|
|
255
266
|
return this.hasAttribute("meteors") && this.getAttribute("meteors") !== "off";
|
|
@@ -275,6 +286,16 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
275
286
|
setMeteorNote(this.#note, this, value);
|
|
276
287
|
this.#gate?.request();
|
|
277
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* 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
|
|
291
|
+
* under the picture (`air-label="off"` takes the line away, for a page that says it itself).
|
|
292
|
+
*/
|
|
293
|
+
get airThickness() {
|
|
294
|
+
return this.#model.airThickness;
|
|
295
|
+
}
|
|
296
|
+
set airThickness(value) {
|
|
297
|
+
this.setAttribute("air-thickness", String(value));
|
|
298
|
+
}
|
|
278
299
|
get centre() {
|
|
279
300
|
return { ...this.#model.centre };
|
|
280
301
|
}
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -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. */
|
package/dist/space/scene.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AIR_QUALITY,
|
|
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(
|
|
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.
|
|
3
|
+
"version": "0.29.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",
|