@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.
@@ -0,0 +1,293 @@
1
+ // A fly-to move over the Earth, for `flyTo` and `goToPlace`: the point under the camera goes along a great circle and the height along a log scale, each a quintic that starts with the speed and
2
+ // the turn the camera has now, so a new move bends the running one instead of stopping it. Pure.
3
+ import { EARTH_RADIUS_KM } from "./ephemeris.js";
4
+ /**
5
+ * The height a descent stops at when the page names none, in kilometres: the whole of a city in view, still sharp with the finer 30 m pictures of the land.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { FLY_HEIGHT_KM } from "@johnmorrisdotca/chikyu-earth/space";
10
+ *
11
+ * console.log(FLY_HEIGHT_KM); // 30
12
+ * ```
13
+ */
14
+ export const FLY_HEIGHT_KM = 30;
15
+ /**
16
+ * The lowest height a descent goes to, in kilometres: the camera stays above the clouds' shell.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { FLY_MIN_KM } from "@johnmorrisdotca/chikyu-earth/space";
21
+ *
22
+ * console.log(FLY_MIN_KM); // 15
23
+ * ```
24
+ */
25
+ export const FLY_MIN_KM = 15;
26
+ /**
27
+ * The height a descent stops at where no finer picture lies under it (the sea, Antarctica, the far north, or no `tiles-finer`), in kilometres: as low as the package's own pictures stay sharp.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { FLY_FLOOR_KM } from "@johnmorrisdotca/chikyu-earth/space";
32
+ *
33
+ * console.log(FLY_FLOOR_KM); // 400
34
+ * ```
35
+ */
36
+ export const FLY_FLOOR_KM = 400;
37
+ const RAD = Math.PI / 180;
38
+ const dot = (p, q) => p[0] * q[0] + p[1] * q[1] + p[2] * q[2];
39
+ const cross = (p, q) => [p[1] * q[2] - p[2] * q[1], p[2] * q[0] - p[0] * q[2], p[0] * q[1] - p[1] * q[0]];
40
+ const scale = (p, k) => [p[0] * k, p[1] * k, p[2] * k];
41
+ const unit = (p) => {
42
+ const length = Math.hypot(p[0], p[1], p[2]);
43
+ return length > 0 ? scale(p, 1 / length) : [0, 0, 1];
44
+ };
45
+ /** `p` less its part along the unit vector `n`: what lies in the plane that touches the sphere at `n`. */
46
+ const along = (p, n) => {
47
+ const k = dot(p, n);
48
+ return [p[0] - n[0] * k, p[1] - n[1] * k, p[2] - n[2] * k];
49
+ };
50
+ // The quintic's three parts on 0 to 1: `ease` goes from 0 to 1 still at both ends, `push` starts with a slope of 1 and `bend` with a second slope of 1, both ending flat at 0.
51
+ const ease = (s) => s * s * s * (10 - 15 * s + 6 * s * s);
52
+ const push = (s) => s - 6 * s ** 3 + 8 * s ** 4 - 3 * s ** 5;
53
+ const bend = (s) => 0.5 * s * s - 1.5 * s ** 3 + 1.5 * s ** 4 - 0.5 * s ** 5;
54
+ /**
55
+ * The unit vector of a longitude and latitude in degrees, in the Earth's axes (x toward longitude 90, y north, z toward longitude 0).
56
+ *
57
+ * @param lon - Degrees east.
58
+ * @param lat - Degrees north.
59
+ * @returns The unit vector.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * import { flyAim } from "@johnmorrisdotca/chikyu-earth/space";
64
+ *
65
+ * console.log(flyAim(0, 90).map((n) => Math.round(n))); // [0, 1, 0]
66
+ * ```
67
+ */
68
+ export function flyAim(lon, lat) {
69
+ const c = Math.cos(lat * RAD);
70
+ return [c * Math.sin(lon * RAD), Math.sin(lat * RAD), c * Math.cos(lon * RAD)];
71
+ }
72
+ /**
73
+ * The longitude and latitude in degrees of a unit vector in the Earth's axes, the inverse of `flyAim`.
74
+ *
75
+ * @param aim - The unit vector.
76
+ * @returns `{ lon, lat }`.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { flyAim, flyLonLat } from "@johnmorrisdotca/chikyu-earth/space";
81
+ *
82
+ * console.log(flyLonLat(flyAim(139.69, 35.69)));
83
+ * ```
84
+ */
85
+ export function flyLonLat(aim) {
86
+ return { lon: Math.atan2(aim[0], aim[2]) / RAD, lat: Math.asin(Math.max(-1, Math.min(1, aim[1]))) / RAD };
87
+ }
88
+ /**
89
+ * How long the turn across takes, in milliseconds: 900 for a short way, up to 2,400 for the far side of the Earth.
90
+ *
91
+ * @param angle - The angle between the two points, in radians.
92
+ * @returns Milliseconds.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { flyAcrossMs } from "@johnmorrisdotca/chikyu-earth/space";
97
+ *
98
+ * console.log(flyAcrossMs(0), flyAcrossMs(Math.PI)); // 900 2400
99
+ * ```
100
+ */
101
+ export const flyAcrossMs = (angle) => 900 + 1500 * Math.min(1, Math.abs(angle) / Math.PI);
102
+ /**
103
+ * How long a descent takes, in milliseconds: 1,200 and half a second more for each time the height is divided by e, at most 5 seconds.
104
+ *
105
+ * @param fromKm - The height it starts from.
106
+ * @param toKm - The height it ends at.
107
+ * @returns Milliseconds.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * import { flyDownMs } from "@johnmorrisdotca/chikyu-earth/space";
112
+ *
113
+ * console.log(Math.round(flyDownMs(20_000, 30)));
114
+ * ```
115
+ */
116
+ export const flyDownMs = (fromKm, toKm) => Math.min(5000, 1200 + 500 * Math.abs(Math.log(Math.max(1e-3, fromKm) / Math.max(1e-3, toKm))));
117
+ /** The time a height still moving takes to come to rest, in milliseconds: it goes on as far as half its speed over that time, so it slows without turning back. */
118
+ const COAST_MS = 900;
119
+ const turnAt = (turn, t) => {
120
+ const s = Math.max(0, Math.min(1, (t - turn.start) / turn.ms));
121
+ const angle = turn.angle * ease(s);
122
+ const side = cross(turn.axis, turn.from);
123
+ const c = Math.cos(angle);
124
+ const n = Math.sin(angle);
125
+ const k = turn.ms * push(s);
126
+ const k2 = turn.ms * turn.ms * bend(s);
127
+ return unit([
128
+ turn.from[0] * c + side[0] * n + turn.v[0] * k + turn.a[0] * k2,
129
+ turn.from[1] * c + side[1] * n + turn.v[1] * k + turn.a[1] * k2,
130
+ turn.from[2] * c + side[2] * n + turn.v[2] * k + turn.a[2] * k2,
131
+ ]);
132
+ };
133
+ const liftAt = (lifts, t) => {
134
+ let value = lifts[0].from;
135
+ for (const lift of lifts) {
136
+ if (t < lift.start)
137
+ break;
138
+ const s = Math.min(1, (t - lift.start) / lift.ms);
139
+ value = lift.from + (lift.to - lift.from) * ease(s) + lift.v * lift.ms * push(s) + lift.a * lift.ms * lift.ms * bend(s);
140
+ }
141
+ return value;
142
+ };
143
+ /**
144
+ * Where a move has the camera at a moment of its clock. Before it starts it is where it began; after it ends, where it ended.
145
+ *
146
+ * @param plan - What `planFly` returned.
147
+ * @param t - The moment, in milliseconds of the clock the plan was made with.
148
+ * @returns The point under the camera and its height.
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * import { flyAt, flyAim, flyLonLat, planFly } from "@johnmorrisdotca/chikyu-earth/space";
153
+ *
154
+ * const plan = planFly({ aim: flyAim(0, 0), v: [0, 0, 0], a: [0, 0, 0], height: Math.log(20_000), hv: 0, ha: 0 }, flyAim(139.69, 35.69), { at: 0, phase: "both", heightKm: 30 });
155
+ * const end = flyAt(plan, plan.end);
156
+ * console.log(flyLonLat(end.aim), Math.round(end.heightKm)); // Tokyo, 30
157
+ * ```
158
+ */
159
+ export function flyAt(plan, t) {
160
+ return { aim: turnAt(plan.turn, t), heightKm: Math.exp(plan.lifts.length > 0 ? liftAt(plan.lifts, t) : plan.height) };
161
+ }
162
+ /** The step the speed and acceleration of a move are read over, in milliseconds. */
163
+ const STEP_MS = 0.5;
164
+ /**
165
+ * Where a move has the camera at a moment and how it is going there: what a new move starts from, so that it carries on with the same speed and turn.
166
+ *
167
+ * @param plan - What `planFly` returned.
168
+ * @param t - The moment, in milliseconds of the plan's clock.
169
+ * @returns The state, with its speeds and accelerations a millisecond.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * import { flyAim, flyStateAt, planFly } from "@johnmorrisdotca/chikyu-earth/space";
174
+ *
175
+ * const plan = planFly({ aim: flyAim(0, 0), v: [0, 0, 0], a: [0, 0, 0], height: Math.log(1000), hv: 0, ha: 0 }, flyAim(90, 0), { at: 0, phase: "across" });
176
+ * const halfway = flyStateAt(plan, plan.end / 2);
177
+ * console.log(Math.hypot(...halfway.v) > 0);
178
+ * ```
179
+ */
180
+ export function flyStateAt(plan, t) {
181
+ // read forward, so a move that has only just begun is read from its own start, not the moment before it
182
+ const p0 = flyAt(plan, t);
183
+ const p1 = flyAt(plan, t + STEP_MS);
184
+ const p2 = flyAt(plan, t + 2 * STEP_MS);
185
+ const aim = p0.aim;
186
+ const v = [0, 1, 2].map((i) => (-3 * p0.aim[i] + 4 * p1.aim[i] - p2.aim[i]) / (2 * STEP_MS));
187
+ const a = [0, 1, 2].map((i) => (p0.aim[i] - 2 * p1.aim[i] + p2.aim[i]) / (STEP_MS * STEP_MS));
188
+ const [h0, h1, h2] = [p0, p1, p2].map((p) => Math.log(p.heightKm));
189
+ return { aim, v: along(v, aim), a: along(a, aim), height: h0, hv: (-3 * h0 + 4 * h1 - h2) / (2 * STEP_MS), ha: (h0 - 2 * h1 + h2) / (STEP_MS * STEP_MS) };
190
+ }
191
+ /**
192
+ * The state of a camera that is not moving: over `aim` at `heightKm`.
193
+ *
194
+ * @param aim - The unit vector of the point under the camera.
195
+ * @param heightKm - Its height in kilometres.
196
+ * @returns The state, with no speed.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * import { flyAim, flyStill } from "@johnmorrisdotca/chikyu-earth/space";
201
+ *
202
+ * console.log(flyStill(flyAim(0, 0), 1000).hv); // 0
203
+ * ```
204
+ */
205
+ export const flyStill = (aim, heightKm) => ({ aim: unit(aim), v: [0, 0, 0], a: [0, 0, 0], height: Math.log(Math.max(1e-3, heightKm)), hv: 0, ha: 0 });
206
+ /**
207
+ * Plan a move from where the camera is and how it is going (`now`) to the point `to`. The turn starts with the camera's own speed and turn and curves to the place along a great circle, slowing to rest over
208
+ * it; the height does the same on a log scale. A height still moving when the move is planned (a descent that a new move cuts short) slows to rest first, without turning back. `across` keeps the height,
209
+ * `down` comes to `heightKm` at once (the turn, if any, beside it), `both` comes down once the turn is over.
210
+ *
211
+ * @param now - Where the camera is and how it is going: `flyStateAt` of the move running, else `flyStill`.
212
+ * @param to - The unit vector of the place.
213
+ * @param options - `at`, the moment on the move's clock; `phase` (`both` by default); `heightKm`, the height to come down to (`FLY_HEIGHT_KM` by default); `acrossMs`, the time of the turn (`flyAcrossMs` of its angle by default).
214
+ * @returns The plan, for `flyAt` and `flyStateAt`.
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * import { flyAim, flyStateAt, planFly } from "@johnmorrisdotca/chikyu-earth/space";
219
+ *
220
+ * const start = { aim: flyAim(0, 0), v: [0, 0, 0] as [number, number, number], a: [0, 0, 0] as [number, number, number], height: Math.log(20_000), hv: 0, ha: 0 };
221
+ * const toTokyo = planFly(start, flyAim(139.69, 35.69), { at: 0 });
222
+ * // half way, the reader asks for London: the new move starts with the speed the first one has
223
+ * const toLondon = planFly(flyStateAt(toTokyo, 800), flyAim(-0.13, 51.51), { at: 800 });
224
+ * console.log(toLondon.end > 800);
225
+ * ```
226
+ */
227
+ export function planFly(now, to, options) {
228
+ const at = options.at;
229
+ const phase = options.phase ?? "both";
230
+ const from = unit(now.aim);
231
+ const target = unit(to);
232
+ const angle = Math.acos(Math.max(-1, Math.min(1, dot(from, target))));
233
+ // the great circle's axis; for two points opposite each other any axis will do, and the way the camera is already going is the one that bends least
234
+ let axis = cross(from, target);
235
+ if (Math.hypot(...axis) < 1e-9)
236
+ axis = cross(from, Math.hypot(...now.v) > 1e-12 ? unit(now.v) : Math.abs(from[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0]);
237
+ const moving = Math.hypot(...now.v) > 1e-12 || Math.hypot(...now.a) > 1e-12;
238
+ const acrossMs = angle < 1e-9 && !moving ? 0 : (options.acrossMs ?? flyAcrossMs(angle));
239
+ const turn = { start: at, ms: Math.max(1, acrossMs), from, to: target, axis: unit(axis), angle, v: along(now.v, from), a: along(now.a, from) };
240
+ const lifts = [];
241
+ let held = now.height;
242
+ let free = at;
243
+ // a height still moving, with no descent to carry on in: it slows to rest first, going on half as far as its speed would carry it over that time
244
+ if (phase !== "down" && (Math.abs(now.hv) > 1e-9 || Math.abs(now.ha) > 1e-9)) {
245
+ held = now.height + 0.5 * now.hv * COAST_MS;
246
+ lifts.push({ start: at, ms: COAST_MS, from: now.height, to: held, v: now.hv, a: now.ha });
247
+ free = at + COAST_MS;
248
+ }
249
+ const across = at + acrossMs;
250
+ if (phase !== "across") {
251
+ const goal = Math.log(Math.max(1e-3, options.heightKm ?? FLY_HEIGHT_KM));
252
+ if (phase === "down")
253
+ lifts.push({ start: at, ms: flyDownMs(Math.exp(now.height), Math.exp(goal)), from: now.height, to: goal, v: now.hv, a: now.ha });
254
+ else if (Math.abs(goal - held) > 1e-9) {
255
+ const start = Math.max(across, free);
256
+ lifts.push({ start, ms: flyDownMs(Math.exp(held), Math.exp(goal)), from: held, to: goal, v: 0, a: 0 });
257
+ }
258
+ }
259
+ const last = lifts[lifts.length - 1];
260
+ return { turn, lifts, height: now.height, across, end: Math.max(across, last ? last.start + last.ms : at) };
261
+ }
262
+ /**
263
+ * The height a descent over a place is held at, in kilometres, or `null` when nothing holds it: a descent comes all the way down only where the finer pictures lie (`tiles-finer` on, over land, from 60
264
+ * degrees south to 80 degrees north, as the survey of the layer found), and stops at `FLY_FLOOR_KM` elsewhere, as low as the package's own pictures stay sharp.
265
+ *
266
+ * @param place - `finer`, whether finer pictures are asked for; `land`, whether the place is on land or near its coast; `lat`, its latitude.
267
+ * @returns The height to hold at, or `null`.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * import { descentFloorKm } from "@johnmorrisdotca/chikyu-earth/space";
272
+ *
273
+ * console.log(descentFloorKm({ finer: true, land: true, lat: 35.69 })); // null: down to the height asked for
274
+ * console.log(descentFloorKm({ finer: true, land: false, lat: 30 })); // 400: the sea
275
+ * ```
276
+ */
277
+ export function descentFloorKm(place) {
278
+ return place.finer && place.land && place.lat >= -60 && place.lat <= 80 ? null : FLY_FLOOR_KM;
279
+ }
280
+ /**
281
+ * The camera's distance from the Earth's centre, in Earth radii, for a height above the ground in kilometres.
282
+ *
283
+ * @param heightKm - The height.
284
+ * @returns The distance.
285
+ *
286
+ * @example
287
+ * ```ts
288
+ * import { flyDistance } from "@johnmorrisdotca/chikyu-earth/space";
289
+ *
290
+ * console.log(flyDistance(6371)); // 2
291
+ * ```
292
+ */
293
+ export const flyDistance = (heightKm) => 1 + heightKm / EARTH_RADIUS_KM;
@@ -10,3 +10,4 @@ export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle
10
10
  export type { BeamStats } from "../beam/layer.ts";
11
11
  export { RIDE_PATH_FADE_KM } from "./path-ribbons.ts";
12
12
  export { createTrailBuilder, TRAIL_DEFAULT_ORBITS, TRAIL_MAX_ORBITS, TRAIL_MAX_POINTS, TRAIL_POINTS_PER_ORBIT, trailOrbits, type PlaceAt, type TrailBuilder } from "./trail.ts";
13
+ export { descentFloorKm, FLY_FLOOR_KM, FLY_HEIGHT_KM, FLY_MIN_KM, flyAcrossMs, flyAim, flyAt, flyDistance, flyDownMs, flyLonLat, flyStateAt, flyStill, planFly, type FlyPhase, type FlyPlan, type FlyPoint, type FlyState } from "./fly.ts";
@@ -11,3 +11,4 @@ export { genericSatellite, satelliteKind } from "./generic-satellite.js";
11
11
  export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam } from "../beam/geometry.js";
12
12
  export { RIDE_PATH_FADE_KM } from "./path-ribbons.js";
13
13
  export { createTrailBuilder, TRAIL_DEFAULT_ORBITS, TRAIL_MAX_ORBITS, TRAIL_MAX_POINTS, TRAIL_POINTS_PER_ORBIT, trailOrbits } from "./trail.js";
14
+ export { descentFloorKm, FLY_FLOOR_KM, FLY_HEIGHT_KM, FLY_MIN_KM, flyAcrossMs, flyAim, flyAt, flyDistance, flyDownMs, flyLonLat, flyStateAt, flyStill, planFly } from "./fly.js";
@@ -176,6 +176,9 @@ export interface SpaceModel {
176
176
  airThickness: number;
177
177
  /** Degrees an hour the cloud picture is made to move eastward against the ground: 0, the default (it is one snapshot, not a forecast). */
178
178
  cloudDrift: number;
179
+ /** 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. */
180
+ cloudFade: number;
181
+ cloudShown: number;
179
182
  /** For the `space` camera: the Earth's turn against the stars (degrees) at the moment the camera was set, so it stays in the stars while the Earth turns beneath; null until the next draw sets it. */
180
183
  cameraSpin: number | null;
181
184
  /** How much of the Earth's turn the space camera takes: 0 holds the stars, 1 turns with the Earth. */
@@ -188,6 +191,8 @@ export interface SpaceModel {
188
191
  };
189
192
  /** The camera's distance at zoom 1 in radii of the body it looks at, as the last draw worked it out from the view's shape and `earth.size`. */
190
193
  fit: number;
194
+ /** The nearest the camera comes to the Earth's centre while it looks at the Earth, in Earth radii: 1.05 (about 320 km up), less once a fly-to has come lower. */
195
+ nearest: number;
191
196
  orbits: boolean;
192
197
  labels: boolean;
193
198
  /** Milliseconds of game time one second of wall time covers (the ephemeris is looked up once per such span). */
@@ -8,6 +8,7 @@ import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
8
8
  import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
9
9
  import { faceOffset, outsidePose, rideGlideMs, ridePose } from "./ride.js";
10
10
  import { stripLights } from "./model-lights.js";
11
+ import { cloudFade, CLOUD_FADE_DEFAULT, CLOUD_WIDTH } from "../realistic/cloud-fade.js";
11
12
  import { newLightFade, stepLightFade } from "../realistic/light-fade.js";
12
13
  import { prefersLessMotion } from "../meteors/note.js";
13
14
  import { genericSatellite, satelliteKind } from "./generic-satellite.js";
@@ -112,10 +113,13 @@ export const newSpaceModel = () => ({
112
113
  camera: "space",
113
114
  airThickness: AIR_THICKNESS_DEFAULT,
114
115
  cloudDrift: 0,
116
+ cloudFade: CLOUD_FADE_DEFAULT,
117
+ cloudShown: 1,
115
118
  cameraSpin: null,
116
119
  follow: 0,
117
120
  earth: { size: DEFAULT_EARTH_SIZE, x: 0.5, y: 0.5 },
118
121
  fit: fitDistance(DEFAULT_EARTH_SIZE, 1),
122
+ nearest: 1.05,
119
123
  orbits: true,
120
124
  labels: true,
121
125
  stepMs: 1000,
@@ -275,7 +279,7 @@ export function createSpaceItem(model, deps) {
275
279
  const cloudMaterial = new three.ShaderMaterial({
276
280
  vertexShader: SURFACE_VERT,
277
281
  fragmentShader: CLOUD_FRAG,
278
- uniforms: { cloudMap: uniform.clouds, sunDir: sunEarth, shift: cloudShift, opacity: { value: 0.9 } },
282
+ uniforms: { cloudMap: uniform.clouds, sunDir: sunEarth, shift: cloudShift, opacity: { value: 0.9 }, fadeGone: { value: 0 }, texelK: { value: 0 } },
279
283
  transparent: true,
280
284
  depthWrite: false,
281
285
  });
@@ -716,12 +720,13 @@ export function createSpaceItem(model, deps) {
716
720
  else {
717
721
  if (way === 1 && focus === "Earth")
718
722
  model.lookBase = { lon: model.centre.lon + spin - frame.spin, lat: baseLat };
719
- distance = Math.max(1.05 * focusRadius, (fit * focusRadius) / Math.max(1e-9, model.view.zoom));
723
+ distance = Math.max((focus === "Earth" ? model.nearest : 1.05) * focusRadius, (fit * focusRadius) / Math.max(1e-9, model.view.zoom));
720
724
  target.set(focusPos[0], focusPos[1], focusPos[2]);
721
725
  camera.position.set(target.x + aim[0] * distance, target.y + aim[1] * distance, target.z + aim[2] * distance);
722
726
  camera.up.set(0, 1, 0);
723
727
  camera.lookAt(target);
724
- camera.near = Math.max(0.0005, distance * 0.02 - focusRadius * 0.5, focusRadius * 0.01);
728
+ // within about 130 km of the ground (a fly-to's descent) the near plane comes in to half the height, or it would cut the ground away
729
+ camera.near = Math.min(Math.max(0.0005, distance * 0.02 - focusRadius * 0.5, focusRadius * 0.01), Math.max(1e-6, (distance - focusRadius) * 0.5));
725
730
  camera.far = Math.max(2000, distance * 4 + (mode === "true" ? 40 * 23_481 : 400));
726
731
  }
727
732
  if (ride && (ride.view === "follow" || ride.view === "above") && typeof ride.target !== "string") {
@@ -871,6 +876,10 @@ export function createSpaceItem(model, deps) {
871
876
  return t < 0 ? null : [eye.x + t * ray.x, eye.y + t * ray.y, eye.z + t * ray.z];
872
877
  },
873
878
  };
879
+ // the clouds give way as their texels grow past the map tiles' pixels, fragment by fragment: the tiles' radius is `focal / distance`, so a texel is `texelK / distance` pixels wide; `cloudShown` is the nearest ground's
880
+ model.cloudShown = cloudFade((focal / away) * model.ratio(), model.cloudFade);
881
+ cloudMaterial.uniforms["fadeGone"].value = model.cloudFade;
882
+ cloudMaterial.uniforms["texelK"].value = (2 * Math.PI * focal * model.ratio()) / CLOUD_WIDTH;
874
883
  tiles.sync({ lon: 0, lat: 0, width: size.width, height: size.height, panX: 0, panY: 0, radius: focal / away, perspective: look }, [sunLocal.value.x, sunLocal.value.y, sunLocal.value.z], true, model.ratio());
875
884
  deps.onTilesDrawn?.();
876
885
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.61.0",
3
+ "version": "0.62.0",
4
4
  "description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on the place you give it, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
5
5
  "keywords": [
6
6
  "earth",