@johnmorrisdotca/chikyu-earth 0.15.0 → 0.17.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
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.17.0 - 2026-11-08
6
+
7
+ - **Sharp close zoom on the realistic Earth, from finer map tiles** (MODULES-645, the loader): `<chikyu-earth-realistic tiles="/tiles/">` (also `earth.tiles`) reads the tile set's `manifest.json`, picks the level from the zoom and the canvas (about one texel to a device pixel; day level 3 then 4, night level 2 then 3), loads only the tiles in view, six at a time, the middle first, and lays them over the package's pictures, which stay as the far view and the fallback. At most 48 tiles are held (about 70 MB of graphics memory); a tile that leaves view is kept 4 seconds and then freed, the oldest first when over the limit; the level drops when the tiles in view would be more. Each tile that arrives asks for one draw (30 a second at most, eight new tiles to a draw); nothing is drawn at rest or out of sight, a lost context comes back with the held tiles, and without the option, without a manifest or for a tile that fails the Earth is drawn as before. A device with no 4096 picture (`max-texture` under 4096, or 2 GB or less of memory) uses no tiles. `earth.stats.tiles` and the `chikyu-tiles` event say what it is doing. New pure parts in `/realistic`: `tileLevel`, `tilesInView`, `coveringTile`, `pointOnEarth`, `tileRect`, `tileColumns`, `tileRows`, `parseManifest`, `TEXEL_SLACK`, `TILE_LIMIT`, `TILE_KEEP_MS`. **The demo's zoom limit on the realistic look goes from 5 to 20** when its tiles are found (the finest tile level is 4 times the widest picture) and stays 5 when they are not. Tests: the level and tile maths (the antimeridian, the poles, a tile bigger than the box) in `test/tiles.test.ts`; a made-up tile set in `e2e/tiles.gl.ts` (requests, drawing over the base, freeing after zoom-out, night tiles, failed tiles, a lost context, batching); a tiles round in `pnpm test:freeze` (GPU objects flat over six zoom rounds). Guide in English and Japanese: `docs/guides/earth-tiles.md`.
8
+ - The demo moves to kazoku-ui ^0.21.0, whose default zoom range is 0.1x to 50x; the flat globe and the embed page keep their 1x to 5x with `zoom-min` and `zoom-max`.
9
+ - **Earth tile pyramid, the data** (MODULES-645, first phase): `scripts/make-earth-tiles.py` (`pnpm tiles`, `pnpm test:tiles`) cuts NASA's Blue Marble Next Generation (September 2004, with bathymetry, 21600 x 10800) and Black Marble 2016 (3 km, 13500 x 6750) into 512 px WebP tiles, day to level 4 (16384 x 8192), night to level 3 (8192 x 4096): 852 tiles, 10.3 MB. Seamless at the antimeridian, tested on a made-up map in CI. Built by `pages.yml` and served at `/tiles/` beside the demo; never in git, never in the npm package. Guide in English and Japanese (`docs/guides/earth-tiles.md`); sources and terms in NOTICE.md.
10
+ - **Why two packages** (MODULES-521): a guide in English and Japanese (`docs/guides/two-packages.md`), a README section and a Guides row say that chikyu-earth is for the Earth only, that the solar system is wakusei-planets', and that the dependency runs one way. Two tested examples: the two packages on one page (`examples/together/`, built and opened by `pnpm test:usage`) and every entry point bundled with wakusei-planets missing.
11
+ - Tests: the ride's glide is measured on the page's own clock, and the Auto-turn step of the drag-rule test turns by an angle read from the controller, not by a 1.5 s stopwatch; the docs site's browser test is the family's newer one (WebKit on a Mac is pressed with Alt+Tab) (MODULES-629).
12
+
13
+ ## 0.16.0 - 2026-11-08
14
+
15
+ - **Space Shuttle flights and the Hubble visits** (MODULES-623), in `@johnmorrisdotca/chikyu-earth/satellites`: `missions()` (the 135 flights, STS-1 to STS-135, with orbiter, liftoff and landing in UTC, the people NASA lists, the main payload in English and Japanese, the catalogue number, and `hubble` on STS-31, 61, 82, 103, 109 and 125), `missionOf(id)` (`"STS-31"`, `"31"`, `31`), `missionElements(file)` and `missionPosition(sets, ms, flight?)` (latitude, longitude, height and speed of the craft at a moment, from the element set nearest in time, by the same SGP4 as `createSatellites`; nothing before liftoff or after landing; nothing from elements over two days away). New types `Mission`, `MissionPosition`, `MissionFile`, `Orbiter` and `HubbleVisit`. Facts: NASA's mission pages (public domain, read 2026-11-08, listed in NOTICE.md).
16
+ - **The demo replays them**: in the space look a Space Shuttle flights row (the Hubble visits and each orbiter's flights as buttons, then the shared replay bar at 600, 3600 and 21600 times real speed) puts the orbiter, and the telescope on its flights, on the globe over the flight's days. The address keeps `mission=` and `time=`. The element sets are `missions/<id>.json` on the demo site (134 files, about 3,100 sets, 410 kB, 180 kB compressed): Space-Track's `gp_history`, asked once with `scripts/missions.ts elements`, cleaned with `clean`; not in the npm package. Data from Space-Track.org (USSPACECOM).
17
+ - Tests: the facts held to the source list read from NASA (`test/recorded/nasa-sts-*.json`), the files to Space-Track's catalogue dates, and a replay's ground track against a second, independent propagator (two-body motion with the J2 drift, its own sidereal time): within 60 km for 90 minutes either side of each element set. `e2e/missions.gl.ts` plays it in the browser. A guide and its Japanese twin: `docs/guides/missions.md`.
18
+
19
+ - **Space-Track.org as the scheduled build's second satellite source** (MODULES-614). After CelesTrak's round, a group whose file is more than 12 hours old is asked of Space-Track's GP class for the catalogue numbers it already holds, at most once in 22 hours for each group, in one login with a six-second pause between asks, stopping at the first answer that is not 200. The login is the Actions secrets `SPACETRACK_USER` and `SPACETRACK_PASSWORD` (locally the same variables or `~/.config/spacetrack/spacetrack.env`), sent only in the login request's body and never printed or stored; without them the build says "CelesTrak only". A group's file and `manifest.json` carry `"source": "spacetrack"` and the demo says so under the globe with the citation "Data from Space-Track.org (USSPACECOM)". Terms and the section read: `docs/satellite-sources.md`, `NOTICE.md`. Demo site only: the package still ships no elements. Tests: `test/spacetrack.test.ts` on a recorded answer and a made-up Space-Track.
20
+ - The browser tests and the Chromium scripts take kazoku-ui's browser lock (kazoku-ui ^0.20.0, MODULES-619).
21
+
3
22
  ## 0.15.0 - 2026-11-04
4
23
 
5
24
  "Put it in your page" is the family's embed panel, on the demo and on the code builder (MODULES-348). No change to the package's drawings.
package/NOTICE.md CHANGED
@@ -33,6 +33,19 @@ material, so no other licence applies. This package is not endorsed by NASA and
33
33
  The credit names are NASA's usual lines for these series; the Visible Earth pages (now at science.nasa.gov/earth/earth-observatory) did not show a credit line in the
34
34
  text read on 2026-11-02, so check them if you need the exact wording for print.
35
35
 
36
+ ## The Earth tiles
37
+
38
+ `scripts/make-earth-tiles.py` cuts two bigger NASA maps into a pyramid of 512 px WebP tiles (docs/guides/earth-tiles.md). The tiles are built in CI and served by GitHub Pages beside the demo at `/tiles/`; they are not in git and not in the npm package. Terms, read on 2026-11-08 at https://www.nasa.gov/nasa-brand-center/images-and-media/ (NASA Images and Media Usage Guidelines): "NASA content – images, audio, video, and media files used in the rendition of 3-dimensional models, such as texture maps and polygon data in any format – generally are not subject to copyright in the United States." and "NASA should be acknowledged as the source of the material." The same page says third-party material NASA uses with permission is marked as copyright protected with the holder's name; neither source below is marked so. Not endorsed by NASA; no NASA insignia or logotype is used.
39
+
40
+ | Layer | Source | Credit |
41
+ |---|---|---|
42
+ | `day` (levels 0 to 4, up to 16384 x 8192) | Blue Marble: Next Generation with topography and bathymetry, September 2004, 21600 x 10800 (https://assets.science.nasa.gov/content/dam/science/esd/eo/images/bmng/bmng-topography-bathymetry/september/world.topo.bathy.200409.3x21600x10800.jpg, SHA-256 863036b622ba3dab4eb4ffb7149730b02cfa433ce49672e9b7267022051e04a2); the same month as `day-*.webp` | "NASA Earth Observatory": the page https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/ (read 2026-11-08) says "Anyone using or republishing Blue Marble: Next Generation please credit “NASA Earth Observatory.”" It was produced by Reto Stöckli, NASA Earth Observatory (NASA Goddard Space Flight Center). |
43
+ | `night` (levels 0 to 3, up to 8192 x 4096) | Earth at Night, Black Marble 2016 colour map at 3 km, 13500 x 6750 (https://assets.science.nasa.gov/content/dam/science/esd/eo/images/imagerecords/144000/144898/BlackMarble_2016_3km.jpg, SHA-256 230aac448ae68c358be433dd518888cccb3a85ccf66f7b44326441c324ad6725; page https://science.nasa.gov/earth/earth-observatory/earth-at-night/maps/, read 2026-11-08) | NASA Earth Observatory, Suomi NPP VIIRS data (the page names no further credit line in its text; check it for print) |
44
+
45
+ The bathymetry-free Blue Marble maps (base map, and base map with topography, on the same Blue Marble page) fall under the same NASA terms; the tiles use the one with bathymetry, as `day-*.webp` does. The clouds are not tiled: NASA's sharper cloud files (Visible Earth 57747, once at eoimages.gsfc.nasa.gov) are no longer served, and the Blue Marble 2002 page (https://science.nasa.gov/earth/earth-observatory/the-blue-marble-true-color-global-imagery-at-1km-resolution/) offers only the 2048 picture already in `clouds-2048.webp`.
46
+
47
+ Where the pyramid is hosted: GitHub Pages of this public repository, which costs nothing (docs/guides/earth-tiles.md). It adds 852 files and 10.3 MB to the site.
48
+
36
49
  ## The Moon's picture
37
50
 
38
51
  `moon-*.webp` is made by `scripts/make-textures.py` from NASA's Scientific Visualization Studio item 4720, "Moon: LROC colour mosaic" (https://svs.gsfc.nasa.gov/4720/,
@@ -54,7 +67,15 @@ Starlink satellite kept (2,231 of 11,155), within the same usage policy, credite
54
67
  18th Space Defense Squadron's general-perturbation (GP) data and, for Starlink, SpaceX's own supplemental elements. It is one download of the `stations` list and one of the `starlink` list on 2026-11-02
55
68
  (about 17:07 UTC), within CelesTrak's usage policy (https://celestrak.org/usage-policy.php, read 2026-11-02: one download per update per list, nothing fetched at a visitor's request), with every fifth Starlink satellite
56
69
  kept (2,232 of 11,156), as numbers only. CelesTrak states no licence or credit rule for the data; it is credited on the demo page, and the demo shows the age of the elements. The tier is "grey" in John's
57
- terms: a snapshot with credit, never a live fetch. The catalogue (`src/satellites/catalogue.ts`) holds names, NORAD numbers and orbit kinds, which are facts, and lines written for this package in its own words (English and Japanese); nothing is copied from NASA, ESA, Wikipedia or any other page. Space-Track's data are not used (it needs an account; its user agreement allows passing on basic data such as TLEs and OMMs only with a citation). docs/satellite-sources.md has every source's terms, read 2026-11-03.
70
+ terms: a snapshot with credit, never a live fetch. The catalogue (`src/satellites/catalogue.ts`) holds names, NORAD numbers and orbit kinds, which are facts, and lines written for this package in its own words (English and Japanese); nothing is copied from NASA, ESA, Wikipedia or any other page. docs/satellite-sources.md has every source's terms, read 2026-11-03.
71
+
72
+ The same build may take a group's element sets from **Space-Track.org** (https://www.space-track.org, U.S. Space Command) when CelesTrak has left the group more than 12 hours old, at most once a day, through its API with John Morris's own account (the login is a repository secret, never in a file). The group's file and `manifest.json` say `"source": "spacetrack"` and the demo says so under the globe. The citation is **"Data from Space-Track.org (USSPACECOM)"**. Terms: the documentation page https://www.space-track.org/documentation, section "Redistribution of Basic SSA Information", read 2026-11-08: "USSPACECOM has provided express blanket approval for transfer/redistribution of basic SSA data and services accessed via www.Space-Track.org conditioned on appropriate citation." Basic SSA data are "Two-Line Elements (TLEs) and Orbital Mean-element Messages (OMMs); SATCAT; and Satellite Decay and Reentry Data." (The page needs a browser; the section was read through a page-reading tool, which returned each sentence in quoted pieces. TODO: John or a browser check of the section's wording.) The page gives no citation form, so this sentence is the package's own. The package ships none of these element sets.
73
+
74
+ ## Space Shuttle missions
75
+
76
+ `src/satellites/missions-data.ts` (in the package) holds the 135 Space Shuttle flights, STS-1 to STS-135: the orbiter, the liftoff and landing, the number of people NASA's page lists, and a few words on the main payload, in English and Japanese. The facts are read from **NASA's mission pages**, `https://www.nasa.gov/mission/sts-<id>/` with `<id>` one of `1 2 3 4 5 6 7 8 9 4 1 b 4 1 c 4 1 d 4 1 g 5 1 a 5 1 c 5 1 d 5 1 b 5 1 g 5 1 f 5 1 i 5 1 j 6 1 a 6 1 b 6 1 c 5 1 l 2 6 2 7 2 9 3 0 2 8 3 4 3 3 3 2 3 6 3 1 4 1 3 8 3 5 3 7 3 9 4 0 4 3 4 8 4 4 4 2 4 5 4 9 5 0 4 6 4 7 5 2 5 3 5 4 5 6 5 5 5 7 5 1 5 8 6 1 6 0 6 2 5 9 6 5 6 4 6 8 6 6 6 3 6 7 7 1 7 0 6 9 7 3 7 4 7 2 7 5 7 6 7 7 7 8 7 9 8 0 8 1 8 2 8 3 8 4 9 4 8 5 8 6 8 7 8 9 9 0 9 1 9 5 8 8 9 6 9 3 1 0 3 9 9 1 0 1 1 0 6 9 2 9 7 9 8 1 0 2 1 0 0 1 0 4 1 0 5 1 0 8 1 0 9 1 1 0 1 1 1 1 1 2 1 1 3 1 0 7 1 1 4 1 2 1 1 1 5 1 1 6 1 1 7 1 1 8 1 2 0 1 2 2 1 2 3 1 2 4 1 2 6 1 1 9 1 2 5 1 2 7 1 2 8 1 2 9 1 3 0 1 3 1 1 3 2 1 3 3 1 3 4 1 3 5`, each read once on 2026-11-08 (a two-second pause between pages; the source list as read is `test/recorded/nasa-sts-2026-11-08.json`, made by `scripts/missions.ts facts`, and `test/missions.test.ts` holds the package's facts to it). NASA content "generally are not subject to copyright in the United States" and NASA is acknowledged as the source; no NASA insignia, logotype or picture is used, and the payload lines are our own words from the pages. STS-107's landing time is the page's "about 9 a.m. EST" on 2003-02-01; the page gives STS-51L no time of liftoff, so it has the date alone.
77
+
78
+ `demo/missions/*.json` (the demo site only, never in the npm package) hold the historical element sets of each flight's craft, 134 files (STS-51L was given none), about 3,100 element sets, 410 kB (180 kB compressed). They are **Space-Track.org** (U.S. Space Command) basic SSA data (SATCAT for the catalogue numbers and dates, `gp_history` for the element sets), asked once on 2026-11-08 with John Morris's own Space-Track account (`scripts/missions.ts elements`; the `gp_history` class is for one ask per object in its lifetime), thinned to one set in three hours at most and cleaned of dated-out-of-flight and typed-over sets (`scripts/missions.ts clean`). Space-Track's "Redistribution of Basic SSA Information" (documentation page, read 2026-11-08, quoted above) allows passing basic SSA data on "conditioned on appropriate citation": **Data from Space-Track.org (USSPACECOM)**, in each file's `source`, the demo's replay note and here. They are site files and not package data, as the package ships no elements (docs/satellite-sources.md).
58
79
 
59
80
  ## Sun position
60
81
 
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
  <p align="center"><strong>A line-drawn globe that turns at the Earth's own rate, and opens centred on where you are.</strong><br>
6
6
  Country outlines in the same thin-line style as Hako Devices and Uchusen Rockets: an orthographic disc, the countries drawn on it, and the rim. One SVG, no canvas.</p>
7
7
 
8
+ <p align="center">Part of <strong>SpaceProgramX (SPX)</strong>, the space packages: <a href="https://github.com/johnmorrisdotca/wakusei-planets">Wakusei Planets</a> · <a href="https://github.com/johnmorrisdotca/hoshi-stars">Hoshi Stars</a> · <a href="https://github.com/johnmorrisdotca/chikyu-earth">Chikyu Earth</a> · <a href="https://github.com/johnmorrisdotca/uchusen-rockets">Uchusen Rockets</a></p>
9
+
8
10
  <p align="center">
9
11
  <a href="https://github.com/johnmorrisdotca/chikyu-earth/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/johnmorrisdotca/chikyu-earth/actions/workflows/ci.yml/badge.svg"></a>
10
12
  <a href="./LICENSE"><img alt="MIT licence" src="https://img.shields.io/badge/licence-MIT-2f5d4a"></a>
@@ -129,6 +131,22 @@ export function ChikyuEarth({ center = "139.7,35.7", look = "thick" }: { center?
129
131
 
130
132
  The guides are also in Japanese (日本語), one language to a page: [docs/guides/ja/](docs/guides/ja/getting-started.md).
131
133
 
134
+ ## Two packages: the Earth here, the rest in wakusei-planets
135
+
136
+ Chikyu Earth is for someone who cares about the Earth only: the countries, day and night, city lights, clouds, markers and the satellites round it. The Sun, the other planets and the moons, where each one is on a date, and the solar system as a scene are [wakusei-planets](https://github.com/johnmorrisdotca/wakusei-planets). The dependency runs one way: wakusei-planets may use chikyu-earth, and chikyu-earth never needs wakusei-planets. A page about a city or a flight installs only this one, a page about Saturn only the other, and a page about the Earth in the solar system both; with both, wakusei-planets' line Earth is this package's globe with the countries:
137
+
138
+ ```sh
139
+ npm install @johnmorrisdotca/chikyu-earth @johnmorrisdotca/wakusei-planets
140
+ ```
141
+
142
+ ```ts no-run
143
+ import "@johnmorrisdotca/chikyu-earth/element";
144
+ import "@johnmorrisdotca/wakusei-planets/element";
145
+ import "@johnmorrisdotca/wakusei-planets/earth";
146
+ ```
147
+
148
+ The full page, the rule and what lives where, each example run by `pnpm test:usage`: [Why two packages](docs/guides/two-packages.md).
149
+
132
150
  ## The Earth from space
133
151
 
134
152
  An optional second look, for a page with room for a real picture: day and night by the real Sun, cities' lights, a sun glint on the sea, a cloud layer and the
@@ -144,14 +162,15 @@ atmosphere at the rim, drawn with three.js through kazoku-ui's shared renderer.
144
162
  ```
145
163
 
146
164
  Needs `three` and `@johnmorrisdotca/kazoku-ui` (both optional peers) and the pictures (1.6 MB, from NASA, in `dist/textures/`). It draws nothing while nothing changes,
147
- at most 30 times a second while it does, in one WebGL context, with textures that grow as you zoom and are freed after. All of it, the budget and the tests:
165
+ at most 30 times a second while it does, in one WebGL context, with textures that grow as you zoom and are freed after. With `tiles="/tiles/"` (a folder of NASA map
166
+ tiles, [how](docs/guides/earth-tiles.md)) it loads only the finer tiles in view, so you can zoom in to 20 times and stay sharp. All of it, the budget and the tests:
148
167
  [docs/realistic.md](docs/realistic.md).
149
168
 
150
169
  ## The Sun, the Moon and the planets
151
170
 
152
171
  `<chikyu-space>` (`@johnmorrisdotca/chikyu-earth/space/element`) places the Earth, the Moon, the Sun, the planets and Pluto (the real ones, with their moons, when [wakusei-planets](https://github.com/johnmorrisdotca/wakusei-planets) is installed: [guide](docs/guides/the-real-planets.md)) where they are at a date and time, with the Moon's phase and the Earth's day side
153
172
  from the light, a compressed scale you can read (and a true one that shows how empty it is), time that runs forwards or backwards, and a zoom from the Earth to the solar system. Positions are
154
- computed in the browser by astronomy-engine (MIT), nothing is fetched. [docs/space.md](docs/space.md).
173
+ computed in the browser by astronomy-engine (MIT), nothing is fetched. [docs/space.md](docs/space.md). The solar system is wakusei-planets' to own, so this view is moving there; this package keeps the Earth and its satellites ([why two packages](docs/guides/two-packages.md)).
155
174
 
156
175
  <p align="center"><img alt="The solar system on 2 November 2026 in the compressed scale: orbits round the Sun, the planets named" src="docs/images/space-solar.png" width="420"></p>
157
176
 
@@ -356,6 +375,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
356
375
  | [The realistic Earth and markers](docs/guides/realistic-and-markers.md) | The Earth from space, markers |
357
376
  | [Satellites](docs/guides/satellites.md) | SGP4 and the space view |
358
377
  | [Ride along](docs/guides/ride-along.md) | A camera on a moving body |
378
+ | [Why two packages](docs/guides/two-packages.md) | This package and wakusei-planets: which to install, alone and together |
359
379
  | [How it stays light](docs/guides/how-it-works.md) | The budget |
360
380
  | [Architecture](docs/guides/architecture.md) | How the layers fit |
361
381
  | [Troubleshooting](docs/guides/troubleshooting.md) | Something does not appear |
@@ -4,6 +4,7 @@ import type { GeoPoint, GlobeView } from "../types.ts";
4
4
  import { lookAt } from "../view.ts";
5
5
  import type { Layer } from "./tiers.ts";
6
6
  import { type ThreeParts } from "./textures.ts";
7
+ import { type TileSet } from "./tile-set.ts";
7
8
  export type { ThreeParts };
8
9
  type Three = ThreeParts;
9
10
  /**
@@ -48,6 +49,8 @@ export interface EarthModel {
48
49
  radius: number;
49
50
  centre: GeoPoint;
50
51
  } | null;
52
+ /** The map tiles laid over the pictures while the scene is built: what they are doing, for a page or a test. */
53
+ tiles: TileSet | null;
51
54
  /** The pixel ratio the textures are chosen for. */
52
55
  ratio(): number;
53
56
  }
@@ -57,6 +60,10 @@ export interface EarthDeps {
57
60
  textureBase: () => string;
58
61
  /** The widest texture, 4096 at most. */
59
62
  cap: () => number;
63
+ /** Where the finer map tiles are (a URL ending with a slash), or `undefined`: the Earth then keeps the package's own pictures. */
64
+ tiles?: () => string | undefined;
65
+ /** Told once when the tile set has been read: the width in pixels of the finest level of each of its layers. */
66
+ onTiles?: (layers: Record<string, number>) => void;
60
67
  /** Clouds' eastward drift against the ground, degrees an hour. */
61
68
  drift: number;
62
69
  invalidate: () => void;
@@ -2,6 +2,7 @@ import { HOME_VIEW, lookAt } from "../view.js";
2
2
  import { ATMOSPHERE_FRAG, ATMOSPHERE_VERT, CLOUD_FRAG, SURFACE_FRAG, SURFACE_VERT } from "./shaders.js";
3
3
  import { subsolarPoint, unitVector } from "./sun.js";
4
4
  import { createTextureSet } from "./textures.js";
5
+ import { createTileSet } from "./tile-set.js";
5
6
  const RAD = Math.PI / 180;
6
7
  /**
7
8
  * The glow reaches this many radii from the centre; the globe at 1x is drawn to fit inside it.
@@ -24,6 +25,7 @@ export const newModel = () => ({
24
25
  lights: true,
25
26
  light: "sun",
26
27
  drawn: null,
28
+ tiles: null,
27
29
  ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
28
30
  });
29
31
  /**
@@ -113,6 +115,8 @@ export function createEarthItem(model, deps) {
113
115
  });
114
116
  const turned = new three.Group();
115
117
  const earth = new three.Mesh(grid, surface);
118
+ const tiles = createTileSet(three, turned, { sunDir, lights: surface.uniforms["lights"], boost: surface.uniforms["boost"], ortho: surface.uniforms["ortho"], water: uniform.water, night: uniform.night }, { assets: deps.assets, base: () => deps.tiles?.(), cap: deps.cap, invalidate: deps.invalidate, ...(deps.onTiles ? { onManifest: deps.onTiles } : {}) });
119
+ model.tiles = tiles;
116
120
  const clouds = new three.Mesh(grid, cloudMaterial);
117
121
  clouds.scale.setScalar(CLOUD_RADIUS);
118
122
  clouds.renderOrder = 2;
@@ -148,6 +152,7 @@ export function createEarthItem(model, deps) {
148
152
  camera.updateProjectionMatrix();
149
153
  model.drawn = { view: { ...view }, time: model.time, radius, centre: { ...model.centre } };
150
154
  textures.sync(radius * model.ratio());
155
+ tiles.sync({ lon: look.lon, lat: look.lat, width: size.width, height: size.height, panX: view.panX, panY: view.panY, radius }, [sunDir.value.x, sunDir.value.y, sunDir.value.z], true, model.ratio());
151
156
  deps.onPose?.({ lon: look.lon, lat: look.lat, radius, cx: size.width / 2 + view.panX, cy: size.height / 2 + view.panY, width: size.width, height: size.height });
152
157
  return false;
153
158
  },
@@ -155,6 +160,8 @@ export function createEarthItem(model, deps) {
155
160
  size = { width: next, height: nextHeight };
156
161
  },
157
162
  dispose() {
163
+ model.tiles = null;
164
+ tiles.dispose();
158
165
  textures.dispose();
159
166
  grid.dispose();
160
167
  surface.dispose();
@@ -4,6 +4,7 @@ import { setSharedRenderer, setThreeLoader } from "./shared.ts";
4
4
  export { setSharedRenderer, setThreeLoader };
5
5
  import type { OverlayHost } from "../markers/layer.ts";
6
6
  import { type Layer } from "./tiers.ts";
7
+ import type { TileStats } from "./tile-set.ts";
7
8
  type EarthLayer = Extract<Layer, "day" | "night" | "clouds" | "water">;
8
9
  /**
9
10
  * What the realistic Earth is doing: `loading` its pictures, `live` and drawing, `unavailable` (no WebGL), `lost` (the GPU took the context; it comes back by itself) or `idle` (another view has the page's one WebGL context; press or focus it to take it).
@@ -32,7 +33,7 @@ export type EarthState = "loading" | "live" | "unavailable" | "lost" | "idle";
32
33
  */
33
34
  export declare const readTime: (value: string | null) => number | "now";
34
35
  /**
35
- * The `<chikyu-earth-realistic>` custom element: the Earth from space, drawn with three.js through kazoku-ui's shared renderer (one WebGL context for the page). It takes `center` (`"lon,lat"`), `time` (`now` or an ISO date; the real Sun at that moment), `clouds="off"`, `lights="off"`, `live-seconds`, `texture-base` (where the pictures are served from) and `max-ratio` (the most device pixels to a CSS pixel the canvas is drawn at, 2 at most, and `0.5` draws at half the size and scales it up: for a background; read when the element connects, and it is the shared renderer's cap for the whole page), and a shared view controller's camera through `setView`. It draws only when something changes, at most 30 times a second, and nothing while it is out of sight or the tab is hidden.
36
+ * The `<chikyu-earth-realistic>` custom element: the Earth from space, drawn with three.js through kazoku-ui's shared renderer (one WebGL context for the page). It takes `center` (`"lon,lat"`), `time` (`now` or an ISO date; the real Sun at that moment), `clouds="off"`, `lights="off"`, `live-seconds`, `texture-base` (where the pictures are served from), `tiles` (where a set of finer map tiles is served from, see the Earth tiles guide: only the tiles in view are loaded, over the package's own pictures, which stay as the far view and the fallback; without it, or when a tile cannot be fetched, the Earth is drawn as before) and `max-ratio` (the most device pixels to a CSS pixel the canvas is drawn at, 2 at most, and `0.5` draws at half the size and scales it up: for a background; read when the element connects, and it is the shared renderer's cap for the whole page), and a shared view controller's camera through `setView`. It draws only when something changes, at most 30 times a second, and nothing while it is out of sight or the tab is hidden.
36
37
  *
37
38
  * @example
38
39
  * ```ts no-run
@@ -42,6 +43,7 @@ export declare const readTime: (value: string | null) => number | "now";
42
43
  * earth.setAttribute("center", "139.7,35.7");
43
44
  * earth.setAttribute("time", "2026-06-21T03:00Z");
44
45
  * earth.setAttribute("texture-base", "/textures/");
46
+ * earth.setAttribute("tiles", "/tiles/");
45
47
  * document.body.append(earth);
46
48
  * ```
47
49
  */
@@ -51,6 +53,9 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
51
53
  connectedCallback(): void;
52
54
  disconnectedCallback(): void;
53
55
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
56
+ /** 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. */
57
+ get tiles(): string | null;
58
+ set tiles(value: string | null);
54
59
  /** A box laid over the Earth for markers (see `@johnmorrisdotca/chikyu-earth/markers`): where it is, the pose of the last draw, and a way to hear the next. */
55
60
  get overlay(): OverlayHost;
56
61
  /** Where the view starts: longitude and latitude; the shared controls' yaw and tilt turn it from there. */
@@ -66,10 +71,11 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
66
71
  set light(value: LightMode);
67
72
  get lights(): boolean;
68
73
  set lights(value: boolean);
69
- /** What the element is doing, for a page or a test: its state, the texture widths held, the draws made. */
74
+ /** What the element is doing, for a page or a test: its state, the texture widths held, the map tiles held, the draws made. */
70
75
  get stats(): {
71
76
  state: EarthState;
72
77
  tiers: Record<EarthLayer, number>;
78
+ tiles: TileStats;
73
79
  draws: number;
74
80
  contexts: number;
75
81
  canvas: {
@@ -46,7 +46,7 @@ export const readTime = (value) => {
46
46
  return Number.isFinite(ms) ? ms : "now";
47
47
  };
48
48
  /**
49
- * The `<chikyu-earth-realistic>` custom element: the Earth from space, drawn with three.js through kazoku-ui's shared renderer (one WebGL context for the page). It takes `center` (`"lon,lat"`), `time` (`now` or an ISO date; the real Sun at that moment), `clouds="off"`, `lights="off"`, `live-seconds`, `texture-base` (where the pictures are served from) and `max-ratio` (the most device pixels to a CSS pixel the canvas is drawn at, 2 at most, and `0.5` draws at half the size and scales it up: for a background; read when the element connects, and it is the shared renderer's cap for the whole page), and a shared view controller's camera through `setView`. It draws only when something changes, at most 30 times a second, and nothing while it is out of sight or the tab is hidden.
49
+ * The `<chikyu-earth-realistic>` custom element: the Earth from space, drawn with three.js through kazoku-ui's shared renderer (one WebGL context for the page). It takes `center` (`"lon,lat"`), `time` (`now` or an ISO date; the real Sun at that moment), `clouds="off"`, `lights="off"`, `live-seconds`, `texture-base` (where the pictures are served from), `tiles` (where a set of finer map tiles is served from, see the Earth tiles guide: only the tiles in view are loaded, over the package's own pictures, which stay as the far view and the fallback; without it, or when a tile cannot be fetched, the Earth is drawn as before) and `max-ratio` (the most device pixels to a CSS pixel the canvas is drawn at, 2 at most, and `0.5` draws at half the size and scales it up: for a background; read when the element connects, and it is the shared renderer's cap for the whole page), and a shared view controller's camera through `setView`. It draws only when something changes, at most 30 times a second, and nothing while it is out of sight or the tab is hidden.
50
50
  *
51
51
  * @example
52
52
  * ```ts no-run
@@ -56,11 +56,12 @@ export const readTime = (value) => {
56
56
  * earth.setAttribute("center", "139.7,35.7");
57
57
  * earth.setAttribute("time", "2026-06-21T03:00Z");
58
58
  * earth.setAttribute("texture-base", "/textures/");
59
+ * earth.setAttribute("tiles", "/tiles/");
59
60
  * document.body.append(earth);
60
61
  * ```
61
62
  */
62
63
  export class ChikyuEarthRealistic extends HTMLElement {
63
- static observedAttributes = ["center", "time", "clouds", "lights", "light", "live-seconds"];
64
+ static observedAttributes = ["center", "time", "clouds", "lights", "light", "live-seconds", "tiles"];
64
65
  #model = newModel();
65
66
  #mode = "now";
66
67
  #view;
@@ -114,6 +115,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
114
115
  assets: taken.renderer.assets,
115
116
  textureBase: () => this.#textureBase(),
116
117
  cap: () => this.#textureCap(),
118
+ tiles: () => this.tiles ?? undefined,
119
+ onTiles: (layers) => this.dispatchEvent(new CustomEvent("chikyu-tiles", { detail: { layers } })),
117
120
  drift: 1.5,
118
121
  invalidate: () => this.#gate?.soon(),
119
122
  onPose: (pose) => {
@@ -167,6 +170,21 @@ export class ChikyuEarthRealistic extends HTMLElement {
167
170
  this.light = readLight(value);
168
171
  else if (name === "live-seconds")
169
172
  this.#startTick();
173
+ else if (name === "tiles")
174
+ this.#gate?.soon();
175
+ }
176
+ /** 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. */
177
+ get tiles() {
178
+ const given = this.getAttribute("tiles");
179
+ if (!given)
180
+ return null;
181
+ return given.endsWith("/") ? given : `${given}/`;
182
+ }
183
+ set tiles(value) {
184
+ if (value === null || value === "")
185
+ this.removeAttribute("tiles");
186
+ else
187
+ this.setAttribute("tiles", value);
170
188
  }
171
189
  /** A box laid over the Earth for markers (see `@johnmorrisdotca/chikyu-earth/markers`): where it is, the pose of the last draw, and a way to hear the next. */
172
190
  get overlay() {
@@ -224,12 +242,13 @@ export class ChikyuEarthRealistic extends HTMLElement {
224
242
  this.#model.lights = value;
225
243
  this.#gate?.soon();
226
244
  }
227
- /** What the element is doing, for a page or a test: its state, the texture widths held, the draws made. */
245
+ /** What the element is doing, for a page or a test: its state, the texture widths held, the map tiles held, the draws made. */
228
246
  get stats() {
229
247
  const stats = this.#taken?.renderer.stats;
230
248
  return {
231
249
  state: this.#state,
232
250
  tiers: { ...this.#tiers },
251
+ tiles: this.#model.tiles?.stats ?? { ready: false, level: null, held: 0, shown: 0, loading: 0, failed: 0, requested: 0 },
233
252
  draws: stats?.draws ?? 0,
234
253
  contexts: stats?.contexts ?? 0,
235
254
  canvas: stats?.canvas ?? { width: 0, height: 0, pixels: 0 },
@@ -3,3 +3,5 @@ export { chooseTier, textureBytes, textureCap, MAX_TEXTURE, TIERS, TEXELS_PER_RA
3
3
  export { createGate, frameCap, type Gate } from "./gate.ts";
4
4
  export { lookAt, discRadius, ATMOSPHERE_OUTER, type LightMode } from "./earth.ts";
5
5
  export type { ThreeParts } from "./earth.ts";
6
+ export { TEXEL_SLACK, coveringTile, parseManifest, pointOnEarth, tileColumns, tileLevel, tileRect, tileRows, tilesInView, type TileCamera, type TileId, type TileLayer, type VisibleTile } from "./tiles.ts";
7
+ export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.ts";
@@ -4,3 +4,5 @@ export { subsolarPoint, unitVector, julianDay } from "./sun.js";
4
4
  export { chooseTier, textureBytes, textureCap, MAX_TEXTURE, TIERS, TEXELS_PER_RADIUS_PIXEL } from "./tiers.js";
5
5
  export { createGate, frameCap } from "./gate.js";
6
6
  export { lookAt, discRadius, ATMOSPHERE_OUTER } from "./earth.js";
7
+ export { TEXEL_SLACK, coveringTile, parseManifest, pointOnEarth, tileColumns, tileLevel, tileRect, tileRows, tilesInView } from "./tiles.js";
8
+ export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.js";
@@ -1,5 +1,12 @@
1
1
  export declare const SURFACE_VERT = "\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvarying vec3 vWorld;\nvoid main() {\n vUv = uv;\n vNormal = normalize(mat3(modelMatrix) * position);\n vWorld = (modelMatrix * vec4(position, 1.0)).xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}";
2
- export declare const SURFACE_FRAG = "\nuniform sampler2D dayMap;\nuniform sampler2D nightMap;\nuniform sampler2D waterMap;\nuniform vec3 sunDir;\nuniform float lights;\nuniform float boost;\nuniform float ortho;\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvarying vec3 vWorld;\nvoid main() {\n vec3 n = normalize(vNormal);\n vec3 toEye = ortho > 0.5 ? vec3(0.0, 0.0, 1.0) : normalize(cameraPosition - vWorld);\n float ndl = dot(n, sunDir);\n float day = smoothstep(-0.10, 0.22, ndl);\n vec3 albedo = texture2D(dayMap, vUv).rgb;\n float water = texture2D(waterMap, vUv).r;\n\n vec3 lit = albedo * (0.07 + 1.0 * pow(max(ndl, 0.0), 0.5));\n float dusk = smoothstep(-0.14, 0.0, ndl) * (1.0 - smoothstep(0.0, 0.30, ndl));\n lit += vec3(0.55, 0.28, 0.14) * dusk * 0.30 * (0.35 + 0.65 * albedo.g);\n\n vec3 h = normalize(sunDir + toEye);\n float glint = pow(max(dot(n, h), 0.0), 220.0) * water * day;\n lit += vec3(1.0, 0.93, 0.80) * glint * 0.7;\n\n vec3 night = texture2D(nightMap, vUv).rgb;\n night = night * night * vec3(1.6, 1.5, 1.3) * lights + night * 0.25;\n vec3 col = mix(night, lit, day);\n col += pow(albedo, vec3(0.75)) * boost * 0.65 * (1.0 - day);\n\n float rim = pow(1.0 - clamp(dot(n, toEye), 0.0, 1.0), 3.0);\n float sunSide = 0.12 + 0.88 * smoothstep(-0.25, 0.5, ndl);\n col += vec3(0.20, 0.45, 1.0) * rim * sunSide * 0.55;\n gl_FragColor = vec4(col, 1.0);\n}";
2
+ export declare const SURFACE_FRAG: string;
3
+ /** The same surface for a map tile: the tile's own program. */
4
+ export declare const TILE_FRAG: string;
5
+ /**
6
+ * A map tile's corners: one 0 to 1 grid for every tile, put on the sphere here from the tile's longitude and latitude range (`rect`: west, north, east, south, in radians) at `radius`.
7
+ * `vUvG` is where the point is on the whole-Earth pictures.
8
+ */
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}";
3
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}";
4
11
  export declare const ATMOSPHERE_VERT = "\nvarying vec3 vPosView;\nvarying vec3 vNormalView;\nvoid main() {\n vec4 view = modelViewMatrix * vec4(position, 1.0);\n vPosView = view.xyz;\n vNormalView = normalize(normalMatrix * position);\n gl_Position = projectionMatrix * view;\n}";
5
12
  export declare const ATMOSPHERE_FRAG = "\nuniform vec3 sunView;\nuniform float outer;\nuniform float ortho;\nvarying vec3 vPosView;\nvarying vec3 vNormalView;\nvoid main() {\n vec3 n = normalize(vNormalView);\n vec3 v = ortho > 0.5 ? vec3(0.0, 0.0, 1.0) : normalize(-vPosView);\n float nz = clamp(dot(n, v), -1.0, 1.0);\n float rho = outer * sqrt(max(0.0, 1.0 - nz * nz));\n float t = clamp((rho - 1.0) / (outer - 1.0), 0.0, 1.0);\n vec2 dir = normalize(n.xy + vec2(1e-5, 0.0));\n float side = smoothstep(-0.40, 0.55, dot(vec3(dir, 0.0), sunView));\n float glow = pow(1.0 - t, 3.0) * (0.10 + 0.90 * side);\n vec3 col = mix(vec3(0.10, 0.22, 0.60), vec3(0.42, 0.68, 1.0), side);\n gl_FragColor = vec4(col, glow * 0.9);\n}";
@@ -10,7 +10,8 @@ void main() {
10
10
  vWorld = (modelMatrix * vec4(position, 1.0)).xyz;
11
11
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
12
12
  }`;
13
- export const SURFACE_FRAG = /* glsl */ `
13
+ /** The surface program. `tile` is the program of a map tile laid over the whole-Earth pictures: the day picture is read at the tile's own coordinates, the rest at the whole Earth's. */
14
+ const surfaceFrag = (tile) => /* glsl */ `
14
15
  uniform sampler2D dayMap;
15
16
  uniform sampler2D nightMap;
16
17
  uniform sampler2D waterMap;
@@ -18,6 +19,7 @@ uniform vec3 sunDir;
18
19
  uniform float lights;
19
20
  uniform float boost;
20
21
  uniform float ortho;
22
+ ${tile ? "uniform vec4 nightRect;\nvarying vec2 vUvG;" : ""}
21
23
  varying vec2 vUv;
22
24
  varying vec3 vNormal;
23
25
  varying vec3 vWorld;
@@ -27,7 +29,7 @@ void main() {
27
29
  float ndl = dot(n, sunDir);
28
30
  float day = smoothstep(-0.10, 0.22, ndl);
29
31
  vec3 albedo = texture2D(dayMap, vUv).rgb;
30
- float water = texture2D(waterMap, vUv).r;
32
+ float water = texture2D(waterMap, ${tile ? "vUvG" : "vUv"}).r;
31
33
 
32
34
  vec3 lit = albedo * (0.07 + 1.0 * pow(max(ndl, 0.0), 0.5));
33
35
  float dusk = smoothstep(-0.14, 0.0, ndl) * (1.0 - smoothstep(0.0, 0.30, ndl));
@@ -37,7 +39,7 @@ void main() {
37
39
  float glint = pow(max(dot(n, h), 0.0), 220.0) * water * day;
38
40
  lit += vec3(1.0, 0.93, 0.80) * glint * 0.7;
39
41
 
40
- vec3 night = texture2D(nightMap, vUv).rgb;
42
+ vec3 night = texture2D(nightMap, ${tile ? "(vUvG - nightRect.xy) / nightRect.zw" : "vUv"}).rgb;
41
43
  night = night * night * vec3(1.6, 1.5, 1.3) * lights + night * 0.25;
42
44
  vec3 col = mix(night, lit, day);
43
45
  col += pow(albedo, vec3(0.75)) * boost * 0.65 * (1.0 - day);
@@ -47,6 +49,31 @@ void main() {
47
49
  col += vec3(0.20, 0.45, 1.0) * rim * sunSide * 0.55;
48
50
  gl_FragColor = vec4(col, 1.0);
49
51
  }`;
52
+ export const SURFACE_FRAG = surfaceFrag(false);
53
+ /** The same surface for a map tile: the tile's own program. */
54
+ export const TILE_FRAG = surfaceFrag(true);
55
+ /**
56
+ * A map tile's corners: one 0 to 1 grid for every tile, put on the sphere here from the tile's longitude and latitude range (`rect`: west, north, east, south, in radians) at `radius`.
57
+ * `vUvG` is where the point is on the whole-Earth pictures.
58
+ */
59
+ export const TILE_VERT = /* glsl */ `
60
+ uniform vec4 rect;
61
+ uniform float radius;
62
+ varying vec2 vUv;
63
+ varying vec2 vUvG;
64
+ varying vec3 vNormal;
65
+ varying vec3 vWorld;
66
+ void main() {
67
+ vUv = uv;
68
+ float lon = mix(rect.x, rect.z, uv.x);
69
+ float lat = mix(rect.y, rect.w, uv.y);
70
+ vec3 unit = vec3(cos(lat) * sin(lon), sin(lat), cos(lat) * cos(lon));
71
+ vUvG = vec2((lon + 3.14159265358979) / 6.28318530717959, 0.5 - lat / 3.14159265358979);
72
+ vNormal = normalize(mat3(modelMatrix) * unit);
73
+ vec4 world = modelMatrix * vec4(unit * radius, 1.0);
74
+ vWorld = world.xyz;
75
+ gl_Position = projectionMatrix * viewMatrix * world;
76
+ }`;
50
77
  export const CLOUD_FRAG = /* glsl */ `
51
78
  uniform sampler2D cloudMap;
52
79
  uniform vec3 sunDir;
@@ -0,0 +1,76 @@
1
+ import type * as THREE from "three";
2
+ import type { AssetCache } from "@johnmorrisdotca/kazoku-ui/renderer";
3
+ import type { ThreeParts } from "./textures.ts";
4
+ import { type TileCamera } from "./tiles.ts";
5
+ /**
6
+ * The most tiles held at once, day and night together, about a megabyte and a third of graphics memory each (a 512 pixel square with its mipmaps).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { TILE_LIMIT } from "@johnmorrisdotca/chikyu-earth/realistic";
11
+ *
12
+ * console.log(TILE_LIMIT);
13
+ * ```
14
+ */
15
+ export declare const TILE_LIMIT = 48;
16
+ /**
17
+ * Milliseconds a tile that is no longer wanted is kept (the view may come straight back) before it is freed.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { TILE_KEEP_MS } from "@johnmorrisdotca/chikyu-earth/realistic";
22
+ *
23
+ * console.log(TILE_KEEP_MS);
24
+ * ```
25
+ */
26
+ export declare const TILE_KEEP_MS = 4000;
27
+ type Three = ThreeParts;
28
+ type Uniform<T> = {
29
+ value: T;
30
+ };
31
+ /** What the tiles share with the surface they are laid over. */
32
+ export interface TileShared {
33
+ sunDir: Uniform<THREE.Vector3>;
34
+ lights: Uniform<number>;
35
+ boost: Uniform<number>;
36
+ ortho: Uniform<number>;
37
+ /** The whole-Earth water and night pictures' uniforms: their value is the picture now held. */
38
+ water: Uniform<THREE.Texture | null>;
39
+ night: Uniform<THREE.Texture | null>;
40
+ }
41
+ export interface TileSetDeps {
42
+ assets: AssetCache;
43
+ /** Where the tile set is, ending with a slash, or `undefined` for none. Read at every draw. */
44
+ base: () => string | undefined;
45
+ /** The widest picture this device holds: tiles are only used where the day picture reaches 4096. */
46
+ cap: () => number;
47
+ /** Ask for one draw. */
48
+ invalidate: () => void;
49
+ /** Told once when a tile set's manifest has been read: the finest width of each layer. */
50
+ onManifest?: (layers: Record<string, number>) => void;
51
+ limit?: number;
52
+ now?: () => number;
53
+ }
54
+ /** What the tile set is doing, for a page or a test. */
55
+ export interface TileStats {
56
+ /** A readable manifest is in hand. */
57
+ ready: boolean;
58
+ /** The level now wanted for the day picture, `null` when the pictures of the package are sharp enough. */
59
+ level: number | null;
60
+ /** Tiles held (loading, loaded, on the sphere or not), and those on the sphere in view. */
61
+ held: number;
62
+ shown: number;
63
+ loading: number;
64
+ /** Tiles that could not be fetched and are not asked for again for a while. */
65
+ failed: number;
66
+ /** Tile fetches made. */
67
+ requested: number;
68
+ }
69
+ export interface TileSet {
70
+ sync(camera: TileCamera, sun: readonly [number, number, number], night: boolean, ratio: number): void;
71
+ readonly stats: TileStats;
72
+ dispose(): void;
73
+ }
74
+ /** Make the set that puts tiles on `parent`, a group that turns with the Earth. */
75
+ export declare function createTileSet(three: Three, parent: THREE.Group, shared: TileShared, deps: TileSetDeps): TileSet;
76
+ export {};