@johnmorrisdotca/chikyu-earth 0.61.0 → 0.62.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 +12 -0
- package/README.md +2 -2
- package/dist/realistic/cloud-fade.d.ts +22 -0
- package/dist/realistic/cloud-fade.js +44 -0
- package/dist/realistic/earth.d.ts +3 -0
- package/dist/realistic/earth.js +6 -1
- package/dist/realistic/element-base.d.ts +2 -0
- package/dist/realistic/element-base.js +8 -1
- package/dist/realistic/shaders.d.ts +1 -1
- package/dist/realistic/shaders.js +10 -0
- package/dist/space/element-base.d.ts +88 -1
- package/dist/space/element-base.js +213 -27
- package/dist/space/fly.d.ts +292 -0
- package/dist/space/fly.js +293 -0
- package/dist/space/index.d.ts +1 -0
- package/dist/space/index.js +1 -0
- package/dist/space/scene.d.ts +5 -0
- package/dist/space/scene.js +12 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.62.0 - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- **A fly-to on the space view, and moves that bend instead of stopping** (MODULES-1582).
|
|
6
|
+
- **`flyTo(lat, lon, { height, phase, smooth, signal })`** on `<chikyu-space>`: across, the Earth turns under the camera at the height it has until the place is below (a great circle, eased), then down to `height` km over it (30 by default, never under 15). `phase` is `across`, `down` or `both`. It resolves to `FlyEnd` (`arrived`, `redirected` or `stopped`, the place, the height then and what held the descent) and sends `chikyu-fly-start` and `chikyu-fly-end`; `stats.fly` says what it is doing. The controls' own turn is paused for it.
|
|
7
|
+
- **A new move bends the running one.** A `flyTo` or `goToPlace` while a move is going starts with the camera's own speed and acceleration and curves to the new place, so the speed and the way it goes are continuous (no stop, no jump); a descent cut short slows to rest without turning back. The realistic Earth's `goToPlace` is unchanged.
|
|
8
|
+
- **A hand ends it where it is**: a drag, pinch, wheel or key (from the element's own hands or a bound bar), or the `signal`. Reduced motion, `smooth: false` or a picture not live yet jumps there.
|
|
9
|
+
- **The floor.** The descent comes all the way down only with `tiles-finer` over land from 60 degrees south to 80 degrees north (the place is looked up in the 1:110m outlines, loaded only then); elsewhere it stops at 400 km (`FLY_FLOOR_KM`, the height the package's own pictures stay sharp, as the site's ride-above floor), and at a `zoom-max` the page set. Below about 320 km the look camera's nearest distance and near plane follow the descent, and the zoom limit is raised under the page's own; a page that never calls `flyTo` draws as before.
|
|
10
|
+
- **Pure parts** in `/space`: `planFly`, `flyAt`, `flyStateAt`, `flyStill`, `flyAim`, `flyLonLat`, `flyAcrossMs`, `flyDownMs`, `flyDistance`, `descentFloorKm` and the `FLY_*` constants, with unit tests (a redirect mid-turn and mid-descent: the speed carries across within 1 per cent, no step stops or jumps, the height never turns back); `e2e/fly.gl.ts` (the same in a real browser, a drag and a signal ending a move, reduced motion jumping 30 km over Tokyo and holding at 400 km over the sea) and a freeze check (one frame at a time, nothing at rest after). The places guide in English and Japanese.
|
|
11
|
+
- **Not yet:** the next tile level is not fetched ahead of the descent; the tiles load as the camera comes down, as they do for a zoom.
|
|
12
|
+
|
|
13
|
+
- **The clouds fade out when the view is close, so the sharp ground shows** (MODULES-1356). The cloud layer is one whole-Earth picture at most 2048 pixels across (about 20 km a texel) drawn over the ground, so from a few hundred kilometres up it blurred the finer tiles under it (a satellite ride's Below step, 486 km up, showed it). Its strength now goes from 1 to 0 as a texel grows from 8 to 32 device pixels wide, worked out from the pixel scale the map tiles use. Both `<chikyu-earth-realistic>` and `<chikyu-space>` do it; the space view does it for each point of the clouds by its own distance from the camera, so the ground under the camera goes sharp and the far ground and the horizon keep their clouds. `cloud-fade="16"` sets the width at which the clouds are gone (32 when left out, 1 to 1000), `cloud-fade="off"` (or `0`) keeps them at any zoom, and `stats.cloudFade` says how much is shown at the nearest ground (the space view) or over the disc (the realistic Earth). Nothing is drawn at rest. A unit test, `e2e/cloud-fade.gl.ts` on both elements, and the earth-tiles guide in English and Japanese.
|
|
14
|
+
|
|
3
15
|
## 0.61.0 - 2026-11-18
|
|
4
16
|
|
|
5
17
|
- **Places get a press event, a size and look each, layers, and names that give way to cities** (MODULES-1578). All of it is optional and a page that uses none of it draws as before.
|
package/README.md
CHANGED
|
@@ -252,7 +252,7 @@ console.log(bodyLabelText("en"), bodyLabelText("ja"), BODY_LABEL_ATTRIBUTES.leng
|
|
|
252
252
|
|
|
253
253
|
`route` on `<chikyu-earth>`, `<chikyu-earth-realistic>` and `<chikyu-space>` draws the line between two places (`lon,lat,lon,lat`). `routeInfo` gives the accurate distance on the Earth's real shape, the great-circle distance, the bearings and a flight time at 900 km/h. The line is off until it is set, and nothing is drawn at rest: [guide](docs/guides/routes.md).
|
|
254
254
|
|
|
255
|
-
`places` on `<chikyu-space>` and `<chikyu-earth-realistic>` marks places on the Earth, each a beam, a pin or a ring (`places-look`) standing out of the ground, turning with the Earth, hidden on its far side and dimmer at night: `kind: "here"` for the reader's own place (brighter, with a quiet pulse) and favourites, quieter, each with an optional `color`. Up to 5,000: the first 32 in sight stand up with their names, the rest are rings in one draw call, crowds are gathered with their count, and `goToPlace(id)` turns the view to one. Names never overlap; nothing is drawn at rest. Each place can have a `layer` (switched with `place-layers`), a `size` or `look` of its own and a `namePriority`, so a harbour is a short mark and its name gives way to a city's; a press on a place sends `chikyu-place-click` with its `id` and `kind`. `here-city` (off by default) names a `here` place with the nearest city within 100 km, in the page's language; kuni is loaded only then. The package never asks for the reader's place and stores or sends nothing: the page asks on a press and rounds the place with `nearby` first: [guide](docs/guides/places.md).
|
|
255
|
+
`places` on `<chikyu-space>` and `<chikyu-earth-realistic>` marks places on the Earth, each a beam, a pin or a ring (`places-look`) standing out of the ground, turning with the Earth, hidden on its far side and dimmer at night: `kind: "here"` for the reader's own place (brighter, with a quiet pulse) and favourites, quieter, each with an optional `color`. Up to 5,000: the first 32 in sight stand up with their names, the rest are rings in one draw call, crowds are gathered with their count, and `goToPlace(id)` turns the view to one. In the space view `flyTo(lat, lon, { height, phase })` goes across at the height the camera has, then down to hover over the place (30 km over land with `tiles-finer`, else 400 km); a new `flyTo` or `goToPlace` bends the running move without stopping it, a hand ends it where it is, and reduced motion jumps there. Names never overlap; nothing is drawn at rest. Each place can have a `layer` (switched with `place-layers`), a `size` or `look` of its own and a `namePriority`, so a harbour is a short mark and its name gives way to a city's; a press on a place sends `chikyu-place-click` with its `id` and `kind`. `here-city` (off by default) names a `here` place with the nearest city within 100 km, in the page's language; kuni is loaded only then. The package never asks for the reader's place and stores or sends nothing: the page asks on a press and rounds the place with `nearby` first: [guide](docs/guides/places.md).
|
|
256
256
|
|
|
257
257
|
```html
|
|
258
258
|
<chikyu-space places='[{"id":"me","lon":-79.4,"lat":43.7,"label":"You are here","kind":"here"}]'></chikyu-space>
|
|
@@ -615,7 +615,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
615
615
|
|
|
616
616
|
## How to cite
|
|
617
617
|
|
|
618
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
618
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.62.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
619
619
|
|
|
620
620
|
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.
|
|
621
621
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The `cloud-fade` default: the texel width in device pixels at which the clouds are gone. 32 pixels of a 2048 texel is 0.6 km of ground a pixel, and the fade starts at 2.4 km a pixel; it keeps the clouds on the horizon seen from a low orbit. */
|
|
2
|
+
export declare const CLOUD_FADE_DEFAULT = 32;
|
|
3
|
+
/** The fade starts at this share of the width that ends it. */
|
|
4
|
+
export declare const CLOUD_FADE_START = 0.25;
|
|
5
|
+
/** The width of the finest cloud picture, in texels round the Earth. */
|
|
6
|
+
export declare const CLOUD_WIDTH: number;
|
|
7
|
+
/**
|
|
8
|
+
* A `cloud-fade` attribute: `off` or `0` is 0 (no fade), a number is the texel width in device pixels at which the clouds are gone (1 to 1000), anything else or leaving it out is the default.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The attribute's text, or null.
|
|
11
|
+
* @returns The width, or 0 for off.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readCloudFade(value: string | null): number;
|
|
14
|
+
/**
|
|
15
|
+
* How much of the clouds to show: 1 while a texel of the cloud picture is no wider than a quarter of `gone` device pixels, 0 from `gone` on, a smooth step between.
|
|
16
|
+
*
|
|
17
|
+
* @param radiusPx - The Earth's radius in device pixels at the nearest ground, as the map tiles read it.
|
|
18
|
+
* @param gone - The texel width in device pixels at which the clouds are gone; 0 or less turns the fade off.
|
|
19
|
+
* @param width - Texels round the Earth in the cloud picture.
|
|
20
|
+
* @returns A strength from 0 to 1.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cloudFade(radiusPx: number, gone: number, width?: number): number;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The clouds give way to the ground when the view is close. The cloud picture is one whole-Earth map at most 2048 pixels across (about 20 km a texel), so from a few hundred kilometres
|
|
2
|
+
// up its texels are many pixels wide and it blurs the sharp ground under it. Its strength goes from 1 to 0 as a texel grows from a few device pixels to many. The figure is the one the
|
|
3
|
+
// map tiles use (`tileLevel`): the disc's radius in device pixels, so a texel is `2 * PI * radiusPx / width` pixels. A state of the view, not of time: it changes only when the view does.
|
|
4
|
+
// The realistic Earth is orthographic, so one radius serves the whole disc and the clouds' opacity is set from it. The space view is in perspective: the cloud shader does the same sum for each fragment with
|
|
5
|
+
// `radiusPx = focal / distance` from the camera to that fragment, so the ground under the camera goes sharp while the far ground and the horizon keep their clouds.
|
|
6
|
+
import { TIERS } from "./tiers.js";
|
|
7
|
+
/** The `cloud-fade` default: the texel width in device pixels at which the clouds are gone. 32 pixels of a 2048 texel is 0.6 km of ground a pixel, and the fade starts at 2.4 km a pixel; it keeps the clouds on the horizon seen from a low orbit. */
|
|
8
|
+
export const CLOUD_FADE_DEFAULT = 32;
|
|
9
|
+
/** The fade starts at this share of the width that ends it. */
|
|
10
|
+
export const CLOUD_FADE_START = 0.25;
|
|
11
|
+
/** The width of the finest cloud picture, in texels round the Earth. */
|
|
12
|
+
export const CLOUD_WIDTH = TIERS.clouds[TIERS.clouds.length - 1];
|
|
13
|
+
/**
|
|
14
|
+
* A `cloud-fade` attribute: `off` or `0` is 0 (no fade), a number is the texel width in device pixels at which the clouds are gone (1 to 1000), anything else or leaving it out is the default.
|
|
15
|
+
*
|
|
16
|
+
* @param value - The attribute's text, or null.
|
|
17
|
+
* @returns The width, or 0 for off.
|
|
18
|
+
*/
|
|
19
|
+
export function readCloudFade(value) {
|
|
20
|
+
if (value === null)
|
|
21
|
+
return CLOUD_FADE_DEFAULT;
|
|
22
|
+
if (value.trim() === "off")
|
|
23
|
+
return 0;
|
|
24
|
+
const width = Number(value);
|
|
25
|
+
if (value.trim() === "" || !Number.isFinite(width) || width < 0)
|
|
26
|
+
return CLOUD_FADE_DEFAULT;
|
|
27
|
+
return width === 0 ? 0 : Math.min(1000, Math.max(1, width));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* How much of the clouds to show: 1 while a texel of the cloud picture is no wider than a quarter of `gone` device pixels, 0 from `gone` on, a smooth step between.
|
|
31
|
+
*
|
|
32
|
+
* @param radiusPx - The Earth's radius in device pixels at the nearest ground, as the map tiles read it.
|
|
33
|
+
* @param gone - The texel width in device pixels at which the clouds are gone; 0 or less turns the fade off.
|
|
34
|
+
* @param width - Texels round the Earth in the cloud picture.
|
|
35
|
+
* @returns A strength from 0 to 1.
|
|
36
|
+
*/
|
|
37
|
+
export function cloudFade(radiusPx, gone, width = CLOUD_WIDTH) {
|
|
38
|
+
if (!(gone > 0))
|
|
39
|
+
return 1;
|
|
40
|
+
const texel = (2 * Math.PI * radiusPx) / width;
|
|
41
|
+
const from = gone * CLOUD_FADE_START;
|
|
42
|
+
const t = Math.min(1, Math.max(0, (texel - from) / (gone - from)));
|
|
43
|
+
return 1 - t * t * (3 - 2 * t);
|
|
44
|
+
}
|
|
@@ -82,6 +82,9 @@ export interface EarthModel {
|
|
|
82
82
|
airThickness: number;
|
|
83
83
|
/** 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. */
|
|
84
84
|
cloudDrift: number;
|
|
85
|
+
/** The texel width in device pixels at which the clouds are gone (`cloud-fade`), 0 for no fade; and the share of the clouds shown at the last draw. */
|
|
86
|
+
cloudFade: number;
|
|
87
|
+
cloudShown: number;
|
|
85
88
|
/** For the `space` camera: the Earth's turn against the stars (degrees) when the camera was set; null until the next draw sets it. */
|
|
86
89
|
cameraSpin: number | null;
|
|
87
90
|
/** Game seconds a second (the clock's speed): the satellites are placed from it. */
|
package/dist/realistic/earth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HOME_VIEW, lookAt } from "../view.js";
|
|
2
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
|
+
import { cloudFade, CLOUD_FADE_DEFAULT } from "./cloud-fade.js";
|
|
4
5
|
import { newLightFade, stepLightFade } from "./light-fade.js";
|
|
5
6
|
import { prefersLessMotion } from "../meteors/note.js";
|
|
6
7
|
import { greenwichSidereal, subsolarPoint, unitVector } from "./sun.js";
|
|
@@ -49,6 +50,8 @@ export const newModel = () => ({
|
|
|
49
50
|
camera: "space",
|
|
50
51
|
airThickness: AIR_THICKNESS_DEFAULT,
|
|
51
52
|
cloudDrift: 0,
|
|
53
|
+
cloudFade: CLOUD_FADE_DEFAULT,
|
|
54
|
+
cloudShown: 1,
|
|
52
55
|
cameraSpin: null,
|
|
53
56
|
speed: 1,
|
|
54
57
|
satellites: newSatelliteState(),
|
|
@@ -247,12 +250,14 @@ export function createEarthItem(model, deps) {
|
|
|
247
250
|
sunDir.value.set(0, 0, 1);
|
|
248
251
|
}
|
|
249
252
|
cloudShift.value = -(((model.time / 3_600_000) * model.cloudDrift) % 360) / 360;
|
|
250
|
-
clouds.visible = model.clouds;
|
|
251
253
|
atmosphere.uniforms["thick"].value = model.airThickness;
|
|
252
254
|
glow.scale.setScalar(airTop(model.airThickness));
|
|
253
255
|
surface.uniforms["lights"].value = model.lights ? 1 - fade.mix : 0;
|
|
254
256
|
surface.uniforms["boost"].value = model.light === "boost" ? 1 : 0;
|
|
255
257
|
const radius = discRadius(size.width, size.height, view.zoom);
|
|
258
|
+
model.cloudShown = cloudFade(radius * model.ratio(), model.cloudFade);
|
|
259
|
+
cloudMaterial.uniforms["opacity"].value = 0.9 * model.cloudShown;
|
|
260
|
+
clouds.visible = model.clouds && model.cloudShown > 0;
|
|
256
261
|
camera.left = (-size.width / 2 - view.panX) / radius;
|
|
257
262
|
camera.right = (size.width / 2 - view.panX) / radius;
|
|
258
263
|
camera.top = (size.height / 2 + view.panY) / radius;
|
|
@@ -423,6 +423,8 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
423
423
|
mix: number;
|
|
424
424
|
fading: boolean;
|
|
425
425
|
};
|
|
426
|
+
/** The share of the clouds shown at the last draw, 1 to 0: they give way to the ground as the cloud picture's texels grow past a few device pixels (`cloud-fade`). The disc is orthographic, so it is the same over the whole disc. */
|
|
427
|
+
cloudFade: number;
|
|
426
428
|
/** The page's paths: asked for, drawn (with the chosen satellite's own), left out over the cap of 16, unmatched, whether the chosen satellite's own orbit is drawn, draw calls they took at the last draw (0 or 1), the path under the mouse and the `chikyu-path-click` events sent. */
|
|
427
429
|
paths: PathStats;
|
|
428
430
|
draws: number;
|
|
@@ -43,6 +43,7 @@ import { framesPerSecond, readSmoothFps, smoothCap, SMOOTH_UP_TO, waitFor, watch
|
|
|
43
43
|
import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
|
|
44
44
|
export { setSharedRenderer, setThreeLoader };
|
|
45
45
|
import { MAX_TEXTURE, TIERS } from "./tiers.js";
|
|
46
|
+
import { readCloudFade } from "./cloud-fade.js";
|
|
46
47
|
import { mayWriteZoomMax, raisedZoomMax } from "./zoom-reach.js";
|
|
47
48
|
const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative;isolation:isolate}" + IMMERSIVE_STYLE + "#stage,#overlay{position:absolute;inset:0}#overlay{pointer-events: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;pointer-events:none}.sp-sat[hidden]{display:none}.sp-sat[data-hover]{transition:opacity 180ms linear}@media (prefers-reduced-motion: reduce){.sp-sat[data-hover]{transition:none}}" + PLACE_STYLE + SKY_STYLE + COUNTRY_NAMES_STYLE + SEA_NAMES_STYLE + CITY_NAMES_STYLE + METEOR_NOTE_STYLE + NOTES_STYLE;
|
|
48
49
|
const RAD = Math.PI / 180;
|
|
@@ -166,7 +167,7 @@ export const readTime = (value) => {
|
|
|
166
167
|
* ```
|
|
167
168
|
*/
|
|
168
169
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
169
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "smooth-fps", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "place-layers", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far"];
|
|
170
|
+
static observedAttributes = ["cloud-drift", "cloud-fade", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "smooth-fps", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "place-layers", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far"];
|
|
170
171
|
#model = newModel();
|
|
171
172
|
#paint = createPaintState();
|
|
172
173
|
#mode = "now";
|
|
@@ -247,6 +248,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
247
248
|
this.#model.light = readLight(this.getAttribute("light"));
|
|
248
249
|
this.#model.camera = readCamera(this.getAttribute("camera"));
|
|
249
250
|
this.#model.cloudDrift = readDrift(this.getAttribute("cloud-drift"));
|
|
251
|
+
this.#model.cloudFade = readCloudFade(this.getAttribute("cloud-fade"));
|
|
250
252
|
this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
|
|
251
253
|
this.#applyBodyLabel();
|
|
252
254
|
this.#door.book.ownOnly(this.getAttribute("data") === "own");
|
|
@@ -495,6 +497,10 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
495
497
|
this.#model.cloudDrift = readDrift(value);
|
|
496
498
|
this.#gate?.soon();
|
|
497
499
|
}
|
|
500
|
+
else if (name === "cloud-fade") {
|
|
501
|
+
this.#model.cloudFade = readCloudFade(value);
|
|
502
|
+
this.#gate?.soon();
|
|
503
|
+
}
|
|
498
504
|
else if (name === "meteors")
|
|
499
505
|
this.meteors = this.#meteorsAsked();
|
|
500
506
|
else if (name === "meteors-strength") {
|
|
@@ -1278,6 +1284,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1278
1284
|
satellites: this.#satelliteStats(),
|
|
1279
1285
|
pace: { ...this.#pace },
|
|
1280
1286
|
lightFade: { mix: this.#model.lightFade.mix, fading: this.#model.lightFade.fading },
|
|
1287
|
+
cloudFade: this.#model.cloudShown,
|
|
1281
1288
|
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
1282
1289
|
tiles: this.#model.tiles?.stats ?? { ready: false, level: null, held: 0, shown: 0, loading: 0, failed: 0, requested: 0, heldBytes: 0, refused: 0, used: {}, finer: null, fading: false },
|
|
1283
1290
|
draws: stats?.draws ?? 0,
|
|
@@ -7,7 +7,7 @@ export declare const TILE_FRAG: string;
|
|
|
7
7
|
* `vUvG` is where the point is on the whole-Earth pictures.
|
|
8
8
|
*/
|
|
9
9
|
export declare const TILE_VERT = "\nuniform vec4 rect;\nuniform float radius;\nvarying vec2 vUv;\nvarying vec2 vUvG;\nvarying vec3 vNormal;\nvarying vec3 vWorld;\nvoid main() {\n vUv = uv;\n float lon = mix(rect.x, rect.z, uv.x);\n float lat = mix(rect.y, rect.w, uv.y);\n vec3 unit = vec3(cos(lat) * sin(lon), sin(lat), cos(lat) * cos(lon));\n vUvG = vec2((lon + 3.14159265358979) / 6.28318530717959, 0.5 - lat / 3.14159265358979);\n vNormal = normalize(mat3(modelMatrix) * unit);\n vec4 world = modelMatrix * vec4(unit * radius, 1.0);\n vWorld = world.xyz;\n gl_Position = projectionMatrix * viewMatrix * world;\n}";
|
|
10
|
-
export declare const CLOUD_FRAG = "\nuniform sampler2D cloudMap;\nuniform vec3 sunDir;\nuniform float shift;\nuniform float opacity;\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvoid main() {\n vec3 n = normalize(vNormal);\n float ndl = dot(n, sunDir);\n float c = texture2D(cloudMap, vec2(vUv.x + shift, vUv.y)).r;\n float a = smoothstep(0.28, 0.88, c) * opacity;\n float day = smoothstep(-0.10, 0.25, ndl);\n vec3 col = mix(vec3(0.015, 0.02, 0.04), vec3(1.0), day * (0.18 + 0.82 * pow(max(ndl, 0.0), 0.45)));\n col += vec3(0.55, 0.28, 0.14) * smoothstep(-0.14, 0.0, ndl) * (1.0 - smoothstep(0.0, 0.25, ndl)) * 0.35;\n gl_FragColor = vec4(col, a);\n}";
|
|
10
|
+
export declare const CLOUD_FRAG = "\nuniform sampler2D cloudMap;\nuniform vec3 sunDir;\nuniform float shift;\nuniform float opacity;\nuniform float fadeGone;\nuniform float texelK;\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvarying vec3 vWorld;\nvoid main() {\n vec3 n = normalize(vNormal);\n float ndl = dot(n, sunDir);\n float c = texture2D(cloudMap, vec2(vUv.x + shift, vUv.y)).r;\n float a = smoothstep(0.28, 0.88, c) * opacity;\n // a texel of the cloud picture is texelK / distance device pixels wide here; the clouds fade out as it grows (cloud-fade.ts, per fragment: the near ground goes sharp, the far ground and the horizon keep their clouds)\n if (fadeGone > 0.0 && texelK > 0.0) {\n float texel = texelK / length(vWorld - cameraPosition);\n float t = clamp((texel - fadeGone * 0.25) / (fadeGone * 0.75), 0.0, 1.0);\n a *= 1.0 - t * t * (3.0 - 2.0 * t);\n }\n float day = smoothstep(-0.10, 0.25, ndl);\n vec3 col = mix(vec3(0.015, 0.02, 0.04), vec3(1.0), day * (0.18 + 0.82 * pow(max(ndl, 0.0), 0.45)));\n col += vec3(0.55, 0.28, 0.14) * smoothstep(-0.14, 0.0, ndl) * (1.0 - smoothstep(0.0, 0.25, ndl)) * 0.35;\n gl_FragColor = vec4(col, a);\n}";
|
|
11
11
|
/** The Moon and other plain bodies: a picture (or a flat colour) lit by the Sun, with a trace of light on the dark side. */
|
|
12
12
|
export declare const BODY_FRAG = "\nuniform sampler2D map;\nuniform vec3 tint;\nuniform float textured;\nuniform float ambient;\nuniform vec3 sunDir;\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvoid main() {\n vec3 n = normalize(vNormal);\n float ndl = dot(n, sunDir);\n vec3 albedo = textured > 0.5 ? texture2D(map, vUv).rgb : tint;\n float lit = smoothstep(-0.04, 0.12, ndl) * (0.10 + 0.95 * pow(max(ndl, 0.0), 0.6));\n gl_FragColor = vec4(albedo * (ambient + lit), 1.0);\n}";
|
|
13
13
|
/** A flat quad facing the camera: the Sun's disc and its glow. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The programs of the realistic Earth, as GLSL strings: the surface (day, night, sun glint), the cloud layer and the Moon and the Sun's glow. The air is `air.ts`.
|
|
2
2
|
// Colours are shaded in the textures' own (sRGB) space: a look, not a radiometric model.
|
|
3
|
+
import { CLOUD_FADE_START } from "./cloud-fade.js";
|
|
3
4
|
export const SURFACE_VERT = /* glsl */ `
|
|
4
5
|
varying vec2 vUv;
|
|
5
6
|
varying vec3 vNormal;
|
|
@@ -130,13 +131,22 @@ uniform sampler2D cloudMap;
|
|
|
130
131
|
uniform vec3 sunDir;
|
|
131
132
|
uniform float shift;
|
|
132
133
|
uniform float opacity;
|
|
134
|
+
uniform float fadeGone;
|
|
135
|
+
uniform float texelK;
|
|
133
136
|
varying vec2 vUv;
|
|
134
137
|
varying vec3 vNormal;
|
|
138
|
+
varying vec3 vWorld;
|
|
135
139
|
void main() {
|
|
136
140
|
vec3 n = normalize(vNormal);
|
|
137
141
|
float ndl = dot(n, sunDir);
|
|
138
142
|
float c = texture2D(cloudMap, vec2(vUv.x + shift, vUv.y)).r;
|
|
139
143
|
float a = smoothstep(0.28, 0.88, c) * opacity;
|
|
144
|
+
// a texel of the cloud picture is texelK / distance device pixels wide here; the clouds fade out as it grows (cloud-fade.ts, per fragment: the near ground goes sharp, the far ground and the horizon keep their clouds)
|
|
145
|
+
if (fadeGone > 0.0 && texelK > 0.0) {
|
|
146
|
+
float texel = texelK / length(vWorld - cameraPosition);
|
|
147
|
+
float t = clamp((texel - fadeGone * ${CLOUD_FADE_START}) / (fadeGone * ${1 - CLOUD_FADE_START}), 0.0, 1.0);
|
|
148
|
+
a *= 1.0 - t * t * (3.0 - 2.0 * t);
|
|
149
|
+
}
|
|
140
150
|
float day = smoothstep(-0.10, 0.25, ndl);
|
|
141
151
|
vec3 col = mix(vec3(0.015, 0.02, 0.04), vec3(1.0), day * (0.18 + 0.82 * pow(max(ndl, 0.0), 0.45)));
|
|
142
152
|
col += vec3(0.55, 0.28, 0.14) * smoothstep(-0.14, 0.0, ndl) * (1.0 - smoothstep(0.0, 0.25, ndl)) * 0.35;
|
|
@@ -17,6 +17,7 @@ import { setThreeLoader } from "../realistic/shared.ts";
|
|
|
17
17
|
import type { LightMode } from "../realistic/earth.ts";
|
|
18
18
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
19
19
|
import type { SatelliteHistory } from "../satellites/history.ts";
|
|
20
|
+
import { type FlyPhase } from "./fly.ts";
|
|
20
21
|
import { type PlanetName } from "./ephemeris.ts";
|
|
21
22
|
import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts";
|
|
22
23
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
@@ -162,6 +163,60 @@ export interface ObserveOptions {
|
|
|
162
163
|
/** Glide to the view (true when left out); false, or a reader who asked for reduced motion, jumps. */
|
|
163
164
|
smooth?: boolean;
|
|
164
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* The options of `flyTo`.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts no-run
|
|
171
|
+
* import type { FlyOptions } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
172
|
+
*
|
|
173
|
+
* const options: FlyOptions = { height: 30, phase: "both" };
|
|
174
|
+
* console.log(options.height);
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export interface FlyOptions {
|
|
178
|
+
/** The height to come down to, in kilometres above the ground (`FLY_HEIGHT_KM`, 30, when left out; never under `FLY_MIN_KM`, 15). `across` keeps the height it has. */
|
|
179
|
+
height?: number;
|
|
180
|
+
/** `across`, `down` or `both` (the default): see `FlyPhase`. */
|
|
181
|
+
phase?: FlyPhase;
|
|
182
|
+
/** Fly (true when left out); false, a reader who asked for reduced motion, or a picture that is not live yet, jumps there. */
|
|
183
|
+
smooth?: boolean;
|
|
184
|
+
/** Ends the move where it is, as a hand on the view does. */
|
|
185
|
+
signal?: AbortSignal;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* How a fly-to ended, as `flyTo` gives it and `chikyu-fly-end` sends it: `arrived`, `redirected` (a new `flyTo` or `goToPlace` took it over, carrying its speed on), or `stopped` (a hand on the view, the
|
|
189
|
+
* signal, a ride, or the element leaving the page); the place, the phase, the camera's height then, and what held the descent up (`held`: `no-finer` where no finer picture lies under the place,
|
|
190
|
+
* `zoom-max` at a `zoom-max` the page set, else `null`).
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts no-run
|
|
194
|
+
* import type { FlyEnd } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
195
|
+
*
|
|
196
|
+
* const say = (end: FlyEnd): string => `${end.reason} at ${Math.round(end.heightKm)} km`;
|
|
197
|
+
* console.log(typeof say);
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export interface FlyEnd {
|
|
201
|
+
reason: "arrived" | "redirected" | "stopped";
|
|
202
|
+
lon: number;
|
|
203
|
+
lat: number;
|
|
204
|
+
phase: FlyPhase;
|
|
205
|
+
heightKm: number;
|
|
206
|
+
held: FlyHeld;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* What held a descent above the height asked for: `no-finer` (no finer picture under the place: `FLY_FLOOR_KM`), `zoom-max` (the page's own `zoom-max`), or `null`.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts no-run
|
|
213
|
+
* import type { FlyHeld } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
214
|
+
*
|
|
215
|
+
* const held: FlyHeld = "no-finer";
|
|
216
|
+
* console.log(held);
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export type FlyHeld = "no-finer" | "zoom-max" | null;
|
|
165
220
|
/**
|
|
166
221
|
* What the camera is riding along with now: the body or satellite, how (`from`, `follow` or `above`), where it looks, the facing it looks round from (`null` when none was chosen), and the distance kept for a satellite.
|
|
167
222
|
*
|
|
@@ -375,7 +430,8 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
375
430
|
/**
|
|
376
431
|
* Turn the view so a place of `places` is in the middle, at a pace a reader can follow (at once with `smooth: false`, for a reader who asked for less motion, or before the picture is live); the zoom stays.
|
|
377
432
|
* The place is named by its `id`, or by its label in any case. The camera must be looking at the Earth: while it rides along or looks at another body nothing moves. The tilt is held to 90 degrees either
|
|
378
|
-
* way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows.
|
|
433
|
+
* way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows. A new `goToPlace` or `flyTo` while it turns does not stop it: the turn keeps its speed and
|
|
434
|
+
* the way it is going and curves to the new place. A hand on the view ends it where it is.
|
|
379
435
|
*
|
|
380
436
|
* @param text - The place's id or label.
|
|
381
437
|
* @param options - `smooth` (true by default).
|
|
@@ -384,6 +440,23 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
384
440
|
goToPlace(text: string, options?: {
|
|
385
441
|
smooth?: boolean;
|
|
386
442
|
}): Promise<Place | undefined>;
|
|
443
|
+
/**
|
|
444
|
+
* Fly the camera to a place: across, the Earth turns under the camera at the height it has until the place is below (along a great circle, eased), then down, a descent to `height` kilometres over
|
|
445
|
+
* it (30 by default). `phase` asks for one part alone, so a page can take a reader there one press at a time. A new `flyTo` or `goToPlace` while one is moving does not stop it: the camera keeps its
|
|
446
|
+
* speed and the way it is going and curves smoothly into the new move, and a descent cut short slows to rest without turning back before the new move goes across. A hand on the view (a drag, a pinch,
|
|
447
|
+
* the wheel, a key) or `signal` ends it where it is; a reader who asked for reduced motion, `smooth: false` or a picture that is not live yet goes there at once. The controls' own turn (Auto-turn) is
|
|
448
|
+
* paused, so the place stays below.
|
|
449
|
+
*
|
|
450
|
+
* The descent comes all the way down only where finer pictures lie under the place (`tiles-finer`, over land from 60 degrees south to 80 degrees north); elsewhere it stops at `FLY_FLOOR_KM` (400 km), and
|
|
451
|
+
* at a `zoom-max` the page set, and says so in `held` and `stats.fly`. Once a fly-to has come below about 320 km the zoom reaches as low as it came. The camera must be looking at the Earth: while it
|
|
452
|
+
* rides along or looks at another body nothing moves. `chikyu-fly-start` is sent when it starts, with `{ lon, lat, phase, heightKm, held }`, and `chikyu-fly-end` when it ends, with what it resolves to.
|
|
453
|
+
*
|
|
454
|
+
* @param lat - Degrees north.
|
|
455
|
+
* @param lon - Degrees east.
|
|
456
|
+
* @param options - `height`, `phase`, `smooth` and `signal` (`FlyOptions`).
|
|
457
|
+
* @returns How it ended, once it has; `undefined` when it cannot fly (a latitude or longitude that is not a number, or the camera not looking at the Earth).
|
|
458
|
+
*/
|
|
459
|
+
flyTo(lat: number, lon: number, options?: FlyOptions): Promise<FlyEnd | undefined>;
|
|
387
460
|
/**
|
|
388
461
|
* Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
|
|
389
462
|
*
|
|
@@ -1063,6 +1136,8 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
1063
1136
|
mix: number;
|
|
1064
1137
|
fading: boolean;
|
|
1065
1138
|
};
|
|
1139
|
+
/** The share of the clouds shown at the last draw, 1 to 0: they give way to the ground as the cloud picture's texels grow past a few device pixels (`cloud-fade`). In the space view it is the share at the nearest ground (the point the map tiles' level is chosen for); the far ground and the horizon keep more, as each fragment is faded by its own distance. */
|
|
1140
|
+
cloudFade: number;
|
|
1066
1141
|
/** The page's paths: asked for, drawn (with the chosen satellite's own), left out over the cap of 16, unmatched, whether the chosen satellite's own orbit is drawn, draw calls they took at the last draw (0 or 1), the path under the mouse and the `chikyu-path-click` events sent. */
|
|
1067
1142
|
paths: PathStats;
|
|
1068
1143
|
ride: {
|
|
@@ -1210,6 +1285,18 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
1210
1285
|
countryNames: CountryNamesStats;
|
|
1211
1286
|
/** The names of oceans, seas and continents: whether `sea-names` is on, the Earth's radius on the screen, the names shown at the last draw, and how many times the layer was laid out. */
|
|
1212
1287
|
seaNames: SeaNamesStats;
|
|
1288
|
+
/**
|
|
1289
|
+
* The fly-to (`flyTo`, and `goToPlace`'s turn): whether one is moving and in which part, the camera's height above the ground in kilometres while it looks at the Earth (`null` otherwise), what held
|
|
1290
|
+
* the last descent up (`held`, as in `FlyEnd`), and how many moves have started and how many were taken over by a new one.
|
|
1291
|
+
*/
|
|
1292
|
+
fly: {
|
|
1293
|
+
flying: boolean;
|
|
1294
|
+
phase: "across" | "down" | null;
|
|
1295
|
+
heightKm: number | null;
|
|
1296
|
+
held: FlyHeld;
|
|
1297
|
+
moves: number;
|
|
1298
|
+
redirects: number;
|
|
1299
|
+
};
|
|
1213
1300
|
};
|
|
1214
1301
|
}
|
|
1215
1302
|
declare global {
|