@johnmorrisdotca/chikyu-earth 0.38.0 → 0.39.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 +8 -0
- package/README.md +2 -1
- package/dist/paint/buffer.d.ts +6 -1
- package/dist/paint/buffer.js +151 -68
- package/dist/paint/texture.d.ts +16 -6
- package/dist/paint/texture.js +46 -27
- package/dist/realistic/earth.d.ts +1 -1
- package/dist/realistic/earth.js +3 -3
- package/dist/realistic/element-base.d.ts +437 -0
- package/dist/realistic/element-base.js +1209 -0
- package/dist/realistic/element.d.ts +2 -431
- package/dist/realistic/element.js +3 -1203
- package/dist/realistic/index.d.ts +1 -1
- package/dist/realistic/no-cultures.d.ts +1 -0
- package/dist/realistic/no-cultures.js +2 -0
- package/dist/realistic/tiles.d.ts +24 -0
- package/dist/realistic/tiles.js +30 -12
- package/dist/sky/culture-source.d.ts +15 -0
- package/dist/sky/culture-source.js +15 -0
- package/dist/sky/cultures.d.ts +1 -0
- package/dist/sky/cultures.js +8 -0
- package/dist/sky/host.js +144 -18
- package/dist/space/element-base.d.ts +624 -0
- package/dist/space/element-base.js +1627 -0
- package/dist/space/element.d.ts +2 -612
- package/dist/space/element.js +3 -1597
- package/dist/space/no-cultures.d.ts +1 -0
- package/dist/space/no-cultures.js +2 -0
- package/dist/space/scene.d.ts +8 -1
- package/dist/space/scene.js +41 -3
- package/package.json +23 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.39.0 - 2026-11-12
|
|
6
|
+
|
|
7
|
+
- **The painted trail follows the orbit at any clock, and costs nothing until it is used** (MODULES-1188). A month laid down at once, or a fast clock, took samples too far apart and drew chords across the map: samples are now at most a third of a trip apart. A clock run backwards laid down nothing for the older end, so the trail shrank: it now fills it in. A coverage swath over the date line was cut at the edge of the map: it now wraps. Switching to a satellite that paints nothing left the old picture on the globe: the cleared picture is sent. The trail's two megabytes and its picture on the graphics card were made in every view, painting or not: they are made when the first satellite is painted, and `clearPaint()` gives them back.
|
|
8
|
+
- **Sharp ground when riding above a satellite, and the model there** (MODULES-1184). `<chikyu-space>` takes `tiles` (attribute and property, as `<chikyu-earth-realistic>` does) and lays the finer map tiles over its Earth: the level is chosen from the pixels a unit of ground takes under the camera, so from 150 km above the ISS the ground is the finest level (4) and from 3,000 km it is level 3, where it was one blurred 4096 picture; only the tiles under the camera are loaded (at most 48, freed after four seconds), a view of the whole Earth asks for none, and nothing is drawn at rest. `stats.tiles` has the tile set's state and `chikyu-tiles` is sent once when a set has been read. `TileCamera` has an optional `perspective` (`TilePerspective`, new in `/realistic`) for a camera with a real place, which `tilesInView` and `pointOnEarth` use in place of the disc; a disc is read as before. The satellite's model (`setSatellitePainter`) was already drawn in the `above` view as in `follow`; the tests now say so at 150 km (`e2e/ride-above-model.gl.ts`, `e2e/ride-above-tiles.gl.ts`). The demo's space view uses its tiles.
|
|
9
|
+
- **A press on a named star or a constellation figure tells the page** (MODULES-1179). `chikyu-sky-pick` is sent on `<chikyu-space>` and `<chikyu-earth-realistic>` when a reader presses or taps one. A star's detail is `{ kind: "star", hr, name, designation, x, y, pointerType }` (`name` as drawn, `x` and `y` CSS pixels inside the element, `pointerType` `mouse`, `pen`, `touch` or `keyboard`). A figure's detail is `{ kind: "constellation", abbreviation, pointerType }`. Each named star and each figure in view is a button, so a keyboard reaches it and Enter picks it, and the pick is announced; the keys `C` and `Shift`+`C` (the next and the previous figure) send it too (`pointerType` `keyboard`). Nothing is drawn at rest.
|
|
10
|
+
- **A build without the sky cultures** (MODULES-1185). `@johnmorrisdotca/chikyu-earth/space/no-cultures` and `@johnmorrisdotca/chikyu-earth/realistic/no-cultures` are `<chikyu-space>` and `<chikyu-earth-realistic>` with no sky culture but the IAU's: nothing under `hoshi-stars/cultures` is imported, so a site's bundler no longer needs a stub for it, and `constellation-culture` is `iau` whatever a page sets (one warning). The default entries are unchanged: they bring in `western`, `japanese` and `chinese`, a dynamic import each. How: the elements' code moved to `element-base.ts` in each folder; `space/element` and `realistic/element` are now that code plus `sky/cultures.ts`, which sets the table the sky layer reads (`setCultureLoaders`). A test reads each entry's imports and finds no `hoshi-stars/cultures` in the two new ones and all three in the default ones, and the usage test bundles the new entries with every such import refused.
|
|
11
|
+
- **The demo takes every planet picture at the widest width again** (MODULES-1175). The demo's `wakusei-planets` is `^0.38.0`, which stops at the widest picture its package ships when a page gives a `textureBase` and no `farBase`, so the demo's cap of 1024 on the painter (and its 404s for 2048) is gone.
|
|
12
|
+
|
|
5
13
|
## 0.38.0 - 2026-11-12
|
|
6
14
|
|
|
7
15
|
- **Paint a satellite's path on the Earth** (MODULES-1167). `paint` on `<chikyu-space>` and `<chikyu-earth-realistic>` is `{ id, length, swath }`. `id` is a NORAD catalogue number or `group:index`. `length` is `1d` (the default), `1w` or `1m` of simulated time. `swath` is `track` (the point under the satellite, the default) or `coverage` (the ground where the satellite is at least 10° above the horizon, from its height). `clearPaint()` takes the trail off. Changing the satellite clears it. The trail is one equirectangular texture on the globe. It is stamped only while simulated time moves, one upload a frame, and nothing at rest or while painting is off. A part older than `length` fades out. The date line and the poles are split so the line does not cross the map. The demo's satellite card has Paint, Clear, and 1 day, 1 week, 1 month.
|
package/README.md
CHANGED
|
@@ -547,6 +547,7 @@ The reference is a site, made from the source's own doc comments: every export h
|
|
|
547
547
|
| `.../realistic`, `.../realistic/element` | The Earth from space; `three` for the element. |
|
|
548
548
|
| `.../markers` | `attachMarkers` and the pure projection, clusters and labels. |
|
|
549
549
|
| `.../space`, `.../space/element` | The Sun, the Moon and the planets; `astronomy-engine` and `three`. |
|
|
550
|
+
| `.../space/no-cultures`, `.../realistic/no-cultures` | The same two elements with no sky culture but the IAU's: nothing under `hoshi-stars/cultures` is in the build ([guide](docs/guides/sky-names.md)). |
|
|
550
551
|
| `.../satellites` | SGP4 for a group of satellites; `satellite.js`. |
|
|
551
552
|
| `.../meteors` | The year's meteor showers, and when and where their meteors fall. No DOM, no dependency. |
|
|
552
553
|
| `.../door` | The data door: sources of your own maps and orbit data with their licence and credit, `creditLine`, the package's own sources. No DOM, no dependency. |
|
|
@@ -608,7 +609,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
608
609
|
|
|
609
610
|
## How to cite
|
|
610
611
|
|
|
611
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
612
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.39.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
612
613
|
|
|
613
614
|
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.
|
|
614
615
|
|
package/dist/paint/buffer.d.ts
CHANGED
|
@@ -32,10 +32,11 @@ export interface PaintState {
|
|
|
32
32
|
/**
|
|
33
33
|
* Stamp the ground crossed since the last call. `sample` is the satellite at a moment, or null when it cannot be placed.
|
|
34
34
|
* Returns true when `data` changed and the picture should upload it. At rest, or with painting off, it returns false.
|
|
35
|
+
* `periodMs` is one trip of the satellite round the Earth: samples are taken often enough that the line between two follows the orbit, however fast the clock. A clock run backwards lays down the older end of the length that it uncovers.
|
|
35
36
|
*/
|
|
36
37
|
step(ms: number, sample: (ms: number) => (LonLat & {
|
|
37
38
|
heightKm: number;
|
|
38
|
-
}) | null): boolean;
|
|
39
|
+
}) | null, periodMs?: number): boolean;
|
|
39
40
|
}
|
|
40
41
|
export declare function createPaintState(): PaintState;
|
|
41
42
|
/** The satellite `id` names, in the groups now set: a NORAD number, or `group:index`. */
|
|
@@ -51,3 +52,7 @@ export declare function paintedGround(groups: Iterable<[string, {
|
|
|
51
52
|
}]>, id: string, ms: number): (LonLat & {
|
|
52
53
|
heightKm: number;
|
|
53
54
|
}) | null;
|
|
55
|
+
/** One trip of the painted satellite round the Earth, in milliseconds, from its mean motion; undefined when it is not found. */
|
|
56
|
+
export declare function paintedPeriod(groups: Iterable<[string, {
|
|
57
|
+
satellites: Satellites;
|
|
58
|
+
}]>, id: string): number | undefined;
|
package/dist/paint/buffer.js
CHANGED
|
@@ -62,67 +62,128 @@ const stampLine = (data, a, b, minute) => {
|
|
|
62
62
|
}
|
|
63
63
|
return added;
|
|
64
64
|
};
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const lat2 = b.lat * Math.PI / 180;
|
|
68
|
-
const dLat = lat2 - lat1;
|
|
69
|
-
const dLon = (b.lon - a.lon) * Math.PI / 180;
|
|
70
|
-
const h = Math.sin(dLat / 2) ** 2 + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2) ** 2;
|
|
71
|
-
return 2 * Math.atan2(Math.sqrt(h), Math.sqrt(Math.max(0, 1 - h)));
|
|
72
|
-
};
|
|
65
|
+
const RAD = Math.PI / 180;
|
|
66
|
+
/** Every pixel within `theta` radians of `point`, row by row: each row's half-width in longitude is worked out, and a cap over the date line wraps to the other edge. */
|
|
73
67
|
const stampCap = (data, point, theta, minute) => {
|
|
74
68
|
if (!(theta > 0))
|
|
75
69
|
return stampDot(data, point, minute, 1);
|
|
76
|
-
const deg = theta
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const south = Math.max(-90, point.lat - deg);
|
|
83
|
-
const north = Math.min(90, point.lat + deg);
|
|
84
|
-
const a = paintPixel(west, north);
|
|
85
|
-
const b = paintPixel(east, south);
|
|
70
|
+
const deg = theta / RAD;
|
|
71
|
+
const sin1 = Math.sin(point.lat * RAD);
|
|
72
|
+
const cos1 = Math.cos(point.lat * RAD);
|
|
73
|
+
const cosTheta = Math.cos(theta);
|
|
74
|
+
const y0 = paintPixel(0, Math.min(90, point.lat + deg)).y;
|
|
75
|
+
const y1 = paintPixel(0, Math.max(-90, point.lat - deg)).y;
|
|
86
76
|
let added = 0;
|
|
87
|
-
const x0 = pole ? 0 : Math.max(0, Math.min(a.x, b.x));
|
|
88
|
-
const x1 = pole ? PAINT_W - 1 : Math.min(PAINT_W - 1, Math.max(a.x, b.x));
|
|
89
|
-
const y0 = Math.max(0, Math.min(a.y, b.y));
|
|
90
|
-
const y1 = Math.min(PAINT_H - 1, Math.max(a.y, b.y));
|
|
91
77
|
for (let y = y0; y <= y1; y += 1) {
|
|
92
|
-
const lat = 90 - (y + 0.5) / PAINT_H * 180;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
78
|
+
const lat = (90 - ((y + 0.5) / PAINT_H) * 180) * RAD;
|
|
79
|
+
const denominator = cos1 * Math.cos(lat);
|
|
80
|
+
const need = cosTheta - sin1 * Math.sin(lat);
|
|
81
|
+
let half;
|
|
82
|
+
if (denominator < 1e-9) {
|
|
83
|
+
if (need > 0)
|
|
84
|
+
continue;
|
|
85
|
+
half = 180;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const ratio = need / denominator;
|
|
89
|
+
if (ratio > 1)
|
|
90
|
+
continue;
|
|
91
|
+
half = ratio <= -1 ? 180 : Math.acos(ratio) / RAD;
|
|
92
|
+
}
|
|
93
|
+
const first = Math.floor(((point.lon - half + 180) / 360) * PAINT_W);
|
|
94
|
+
const last = Math.floor(((point.lon + half + 180) / 360) * PAINT_W);
|
|
95
|
+
if (last - first >= PAINT_W - 1) {
|
|
96
|
+
for (let x = 0; x < PAINT_W; x += 1)
|
|
97
|
+
if (write(data, x, y, minute))
|
|
98
|
+
added += 1;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
for (let x = first; x <= last; x += 1)
|
|
102
|
+
if (write(data, ((x % PAINT_W) + PAINT_W) % PAINT_W, y, minute))
|
|
103
|
+
added += 1;
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
return added;
|
|
102
107
|
};
|
|
103
108
|
const stampGround = (data, swath, ground, previous, minute) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
const theta = swath === "coverage" ? coverageAngleRad(ground.heightKm) : 0;
|
|
110
|
+
if (swath === "coverage" && previous === null)
|
|
111
|
+
return { added: stampCap(data, ground, theta, minute), at: ground };
|
|
112
|
+
if (swath === "track" && previous === null)
|
|
107
113
|
return { added: stampDot(data, ground, minute, 1), at: ground };
|
|
114
|
+
// a line is made of steps 0.4 of a degree long; a swath of caps that overlap, a step of about seven tenths of the cap's radius
|
|
115
|
+
const points = trackSteps(previous, ground, swath === "coverage" ? Math.max(1, (theta / RAD) * 0.7) : 0.4);
|
|
108
116
|
let added = 0;
|
|
109
117
|
let cursor = previous;
|
|
110
|
-
for (const point of
|
|
111
|
-
|
|
112
|
-
added +=
|
|
118
|
+
for (const point of points) {
|
|
119
|
+
if (swath === "coverage")
|
|
120
|
+
added += stampCap(data, point, theta, minute);
|
|
121
|
+
else
|
|
122
|
+
for (const [from, to] of splitDateLine(cursor, point))
|
|
123
|
+
added += stampLine(data, from, to, minute);
|
|
113
124
|
cursor = point;
|
|
114
125
|
}
|
|
115
126
|
return { added, at: cursor };
|
|
116
127
|
};
|
|
128
|
+
/** A stamp's age in minutes, from the 16 bits it holds. */
|
|
129
|
+
const ageOf = (then, now) => {
|
|
130
|
+
let age = now - then;
|
|
131
|
+
if (age < -32768)
|
|
132
|
+
age += 65536;
|
|
133
|
+
if (age > 32767)
|
|
134
|
+
age -= 65536;
|
|
135
|
+
return age;
|
|
136
|
+
};
|
|
137
|
+
/** The longest gap between two samples that a line may leap: a twentieth of a trip, and between 30 seconds and four minutes. The samples are never more than a third of a trip apart, however many that takes. */
|
|
138
|
+
const MAX_GAP = 240_000;
|
|
139
|
+
const MIN_GAP = 30_000;
|
|
140
|
+
const FRAME_SAMPLES = 600;
|
|
141
|
+
const REBUILD_SAMPLES = { track: 4000, coverage: 1500 };
|
|
142
|
+
const gapOf = (periodMs) => (periodMs !== undefined && periodMs > 0 ? Math.max(MIN_GAP, Math.min(MAX_GAP, periodMs / 20)) : 20_000);
|
|
117
143
|
export function createPaintState() {
|
|
118
|
-
|
|
144
|
+
// the two megabytes are taken when the first satellite is painted and given back by `clear`, not made with the view
|
|
145
|
+
let buffer = null;
|
|
146
|
+
const grab = () => (buffer ??= new Uint8Array(PAINT_W * PAINT_H * 4));
|
|
119
147
|
let spec = null;
|
|
120
148
|
let pixels = 0;
|
|
121
149
|
let lastMs = Number.NaN;
|
|
150
|
+
/** The last point stamped and the way the clock was going then, so a line carries on from it. */
|
|
122
151
|
let previous = null;
|
|
123
|
-
let
|
|
152
|
+
let heading = 0;
|
|
153
|
+
/** The buffer was emptied since the last step: the picture must be sent even if nothing new was stamped. */
|
|
154
|
+
let stale = false;
|
|
155
|
+
const reset = () => {
|
|
156
|
+
buffer?.fill(0);
|
|
157
|
+
pixels = 0;
|
|
158
|
+
lastMs = Number.NaN;
|
|
159
|
+
previous = null;
|
|
160
|
+
heading = 0;
|
|
161
|
+
stale = true;
|
|
162
|
+
};
|
|
163
|
+
/** Take out what has fallen out of the length (or is later than the clock now says). */
|
|
164
|
+
const dropOld = (data, now, span) => {
|
|
165
|
+
let dropped = false;
|
|
166
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
167
|
+
if (data[i + 3] === 0)
|
|
168
|
+
continue;
|
|
169
|
+
const then = ((data[i] ?? 0) << 8) | (data[i + 1] ?? 0);
|
|
170
|
+
const age = ageOf(then, now);
|
|
171
|
+
// a minute of slack at each end, for the rounding of the stamp's minute
|
|
172
|
+
if (age > span + 1 || age < -1) {
|
|
173
|
+
data[i] = 0;
|
|
174
|
+
data[i + 1] = 0;
|
|
175
|
+
data[i + 2] = 0;
|
|
176
|
+
data[i + 3] = 0;
|
|
177
|
+
pixels -= 1;
|
|
178
|
+
dropped = true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return dropped;
|
|
182
|
+
};
|
|
124
183
|
const self = {
|
|
125
|
-
data
|
|
184
|
+
get data() {
|
|
185
|
+
return grab();
|
|
186
|
+
},
|
|
126
187
|
width: PAINT_W,
|
|
127
188
|
height: PAINT_H,
|
|
128
189
|
get pixels() {
|
|
@@ -153,55 +214,71 @@ export function createPaintState() {
|
|
|
153
214
|
const swath = paintSwathOf(next.swath);
|
|
154
215
|
if (spec && spec.id === id && spec.length === length && spec.swath === swath)
|
|
155
216
|
return;
|
|
156
|
-
|
|
157
|
-
pixels = 0;
|
|
158
|
-
lastMs = Number.NaN;
|
|
159
|
-
previous = null;
|
|
217
|
+
reset();
|
|
160
218
|
spec = { id, length, swath };
|
|
161
219
|
},
|
|
162
220
|
clear() {
|
|
163
|
-
|
|
164
|
-
pixels = 0;
|
|
165
|
-
lastMs = Number.NaN;
|
|
166
|
-
previous = null;
|
|
221
|
+
reset();
|
|
167
222
|
spec = null;
|
|
168
|
-
|
|
223
|
+
buffer = null;
|
|
169
224
|
},
|
|
170
|
-
step(ms, sample) {
|
|
225
|
+
step(ms, sample, periodMs) {
|
|
171
226
|
if (!spec) {
|
|
172
|
-
const upload =
|
|
173
|
-
|
|
227
|
+
const upload = stale;
|
|
228
|
+
stale = false;
|
|
174
229
|
return upload;
|
|
175
230
|
}
|
|
176
231
|
if (!Number.isFinite(ms))
|
|
177
232
|
return false;
|
|
178
|
-
if (Number.isFinite(lastMs) && ms === lastMs)
|
|
179
|
-
|
|
233
|
+
if (Number.isFinite(lastMs) && ms === lastMs) {
|
|
234
|
+
const upload = stale;
|
|
235
|
+
stale = false;
|
|
236
|
+
return upload;
|
|
237
|
+
}
|
|
238
|
+
const data = grab();
|
|
180
239
|
const length = LENGTH_MS[spec.length];
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
240
|
+
const gap = gapOf(periodMs);
|
|
241
|
+
let dirty = stale;
|
|
242
|
+
stale = false;
|
|
243
|
+
/** Stamp the satellite's place at each of `times`, one line from the one before. */
|
|
244
|
+
const lay = (times, way) => {
|
|
245
|
+
if (way !== heading)
|
|
246
|
+
previous = null;
|
|
247
|
+
heading = way;
|
|
248
|
+
for (const at of times) {
|
|
249
|
+
const ground = sample(at);
|
|
250
|
+
if (!ground) {
|
|
251
|
+
previous = null;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const stamped = stampGround(data, spec.swath, ground, previous, paintMinute(at));
|
|
255
|
+
pixels += stamped.added;
|
|
256
|
+
previous = stamped.at;
|
|
257
|
+
dirty = true;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const between = (from, to, cap) => {
|
|
261
|
+
const span = Math.abs(to - from);
|
|
262
|
+
const count = Math.max(Math.min(cap, Math.max(1, Math.ceil(span / gap))), periodMs === undefined ? 1 : Math.ceil(span / (periodMs / 3)));
|
|
263
|
+
return Array.from({ length: count + 1 }, (_, i) => from + ((to - from) * i) / count);
|
|
190
264
|
};
|
|
191
265
|
if (!Number.isFinite(lastMs) || Math.abs(ms - lastMs) > length) {
|
|
266
|
+
// the first moment, or a jump: the whole length is laid down again, oldest first
|
|
192
267
|
data.fill(0);
|
|
193
268
|
pixels = 0;
|
|
194
269
|
previous = null;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
270
|
+
heading = 1;
|
|
271
|
+
lay(between(ms - length, ms, REBUILD_SAMPLES[spec.swath]), 1);
|
|
272
|
+
}
|
|
273
|
+
else if (ms > lastMs) {
|
|
274
|
+
lay(between(lastMs, ms, FRAME_SAMPLES), 1);
|
|
198
275
|
}
|
|
199
276
|
else {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
for (let i = 1; i <= steps; i += 1)
|
|
203
|
-
put(lastMs + (span * i) / steps);
|
|
277
|
+
// backwards: the newer end falls away below, and the older end, which the clock has just uncovered, is laid down
|
|
278
|
+
lay(between(lastMs - length, ms - length, FRAME_SAMPLES), -1);
|
|
204
279
|
}
|
|
280
|
+
if (dropOld(data, paintMinute(ms), length / MINUTE))
|
|
281
|
+
dirty = true;
|
|
205
282
|
lastMs = ms;
|
|
206
283
|
return dirty;
|
|
207
284
|
},
|
|
@@ -236,3 +313,9 @@ export function paintedGround(groups, id, ms) {
|
|
|
236
313
|
return null;
|
|
237
314
|
return groundUnder(scratch[0], scratch[1], scratch[2], ms);
|
|
238
315
|
}
|
|
316
|
+
/** One trip of the painted satellite round the Earth, in milliseconds, from its mean motion; undefined when it is not found. */
|
|
317
|
+
export function paintedPeriod(groups, id) {
|
|
318
|
+
const found = findPainted(groups, id);
|
|
319
|
+
const motion = found?.satellites.sets[found.index]?.MEAN_MOTION;
|
|
320
|
+
return motion !== undefined && motion > 0 ? DAY / motion : undefined;
|
|
321
|
+
}
|
package/dist/paint/texture.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type * as THREE from "three";
|
|
2
2
|
import type { ThreeParts } from "../realistic/textures.ts";
|
|
3
|
+
/** Where the trail's picture comes from: its pixels are asked for only while it is on, so a page that paints nothing never makes them. */
|
|
4
|
+
export interface PaintSource {
|
|
5
|
+
data(): Uint8Array;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
3
9
|
export interface PaintTexture {
|
|
4
|
-
texture: THREE.Texture;
|
|
5
10
|
uniforms: {
|
|
6
11
|
paintMap: {
|
|
7
|
-
value: THREE.Texture;
|
|
12
|
+
value: THREE.Texture | null;
|
|
8
13
|
};
|
|
9
14
|
paintNow: {
|
|
10
15
|
value: number;
|
|
@@ -16,9 +21,14 @@ export interface PaintTexture {
|
|
|
16
21
|
value: number;
|
|
17
22
|
};
|
|
18
23
|
};
|
|
19
|
-
/**
|
|
20
|
-
|
|
24
|
+
/** Whether the picture is on the graphics card now. */
|
|
25
|
+
readonly held: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Make the picture when painting goes on (and send it), send it again when `changed`, and give it back when painting is off.
|
|
28
|
+
* With painting off nothing is made and nothing is held.
|
|
29
|
+
*/
|
|
30
|
+
sync(on: boolean, changed: boolean): void;
|
|
21
31
|
dispose(): void;
|
|
22
32
|
}
|
|
23
|
-
/** A texture over
|
|
24
|
-
export declare function createPaintTexture(three: ThreeParts,
|
|
33
|
+
/** A texture over the trail (equirectangular, north in the first row), made on the first paint and freed on clear. The same uniforms go on the sphere and on any tile laid over it. */
|
|
34
|
+
export declare function createPaintTexture(three: ThreeParts, source: PaintSource): PaintTexture;
|
package/dist/paint/texture.js
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function createPaintTexture(three, data, width = PAINT_W, height = PAINT_H) {
|
|
1
|
+
/** A texture over the trail (equirectangular, north in the first row), made on the first paint and freed on clear. The same uniforms go on the sphere and on any tile laid over it. */
|
|
2
|
+
export function createPaintTexture(three, source) {
|
|
4
3
|
const DataTexture = three.DataTexture;
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
texture
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
const uniforms = {
|
|
5
|
+
paintMap: { value: null },
|
|
6
|
+
paintNow: { value: 0 },
|
|
7
|
+
paintSpan: { value: 1440 },
|
|
8
|
+
paintOn: { value: 0 },
|
|
9
|
+
};
|
|
10
|
+
let texture = null;
|
|
11
|
+
const make = () => {
|
|
12
|
+
const data = source.data();
|
|
13
|
+
const made = DataTexture ? new DataTexture(data, source.width, source.height) : new three.Texture();
|
|
14
|
+
if (!DataTexture)
|
|
15
|
+
made.image = { data, width: source.width, height: source.height };
|
|
16
|
+
made.generateMipmaps = false;
|
|
17
|
+
made.flipY = false;
|
|
18
|
+
made.magFilter = three.LinearFilter;
|
|
19
|
+
made.minFilter = three.LinearFilter;
|
|
20
|
+
made.wrapS = three.ClampToEdgeWrapping;
|
|
21
|
+
made.wrapT = three.ClampToEdgeWrapping;
|
|
22
|
+
const space = three.NoColorSpace;
|
|
23
|
+
if (space)
|
|
24
|
+
made.colorSpace = space;
|
|
25
|
+
made.needsUpdate = true;
|
|
26
|
+
return made;
|
|
27
|
+
};
|
|
28
|
+
const free = () => {
|
|
29
|
+
texture?.dispose();
|
|
30
|
+
texture = null;
|
|
31
|
+
uniforms.paintMap.value = null;
|
|
32
|
+
};
|
|
18
33
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
paintNow: { value: 0 },
|
|
23
|
-
paintSpan: { value: 1440 },
|
|
24
|
-
paintOn: { value: 0 },
|
|
25
|
-
},
|
|
26
|
-
upload() {
|
|
27
|
-
texture.needsUpdate = true;
|
|
34
|
+
uniforms,
|
|
35
|
+
get held() {
|
|
36
|
+
return texture !== null;
|
|
28
37
|
},
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
sync(on, changed) {
|
|
39
|
+
if (!on) {
|
|
40
|
+
free();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (texture === null) {
|
|
44
|
+
texture = make();
|
|
45
|
+
uniforms.paintMap.value = texture;
|
|
46
|
+
}
|
|
47
|
+
else if (changed)
|
|
48
|
+
texture.needsUpdate = true;
|
|
31
49
|
},
|
|
50
|
+
dispose: free,
|
|
32
51
|
};
|
|
33
52
|
}
|
|
@@ -138,7 +138,7 @@ export interface EarthDeps {
|
|
|
138
138
|
onPlaceRings?: (drawn: boolean) => void;
|
|
139
139
|
/** The painted satellite trail, when the element has one. Read at every draw; nothing is uploaded while `step` returns false. */
|
|
140
140
|
paint?: {
|
|
141
|
-
data: Uint8Array;
|
|
141
|
+
data(): Uint8Array;
|
|
142
142
|
width: number;
|
|
143
143
|
height: number;
|
|
144
144
|
step(ms: number): boolean;
|
package/dist/realistic/earth.js
CHANGED
|
@@ -151,7 +151,7 @@ export function createEarthItem(model, deps) {
|
|
|
151
151
|
fragmentShader: SURFACE_FRAG,
|
|
152
152
|
uniforms: { dayMap: uniform.day, nightMap: uniform.night, waterMap: uniform.water, cloudMap: uniform.clouds, sunDir, sunLocal, cloudShift, lights: { value: 1 }, boost: { value: 0 }, ortho: { value: 1 } },
|
|
153
153
|
});
|
|
154
|
-
const paint = createPaintTexture(three, deps.paint?.data ?? new Uint8Array(4), deps.paint?.width ?? 1, deps.paint?.height ?? 1);
|
|
154
|
+
const paint = createPaintTexture(three, { data: () => deps.paint?.data() ?? new Uint8Array(4), width: deps.paint?.width ?? 1, height: deps.paint?.height ?? 1 });
|
|
155
155
|
Object.assign(surface.uniforms, paint.uniforms);
|
|
156
156
|
const cloudMaterial = new three.ShaderMaterial({
|
|
157
157
|
vertexShader: SURFACE_VERT,
|
|
@@ -309,8 +309,8 @@ export function createEarthItem(model, deps) {
|
|
|
309
309
|
}
|
|
310
310
|
gridLayer?.sync(radius);
|
|
311
311
|
if (deps.paint) {
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
const changed = deps.paint.step(model.time);
|
|
313
|
+
paint.sync(deps.paint.on(), changed);
|
|
314
314
|
paint.uniforms.paintNow.value = paintMinute(model.time);
|
|
315
315
|
paint.uniforms.paintSpan.value = deps.paint.span();
|
|
316
316
|
paint.uniforms.paintOn.value = deps.paint.on() ? 1 : 0;
|