@johnmorrisdotca/chikyu-earth 0.46.0 → 0.46.2
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/NOTICE.md +10 -0
- package/README.md +2 -2
- package/dist/door/gibs.d.ts +171 -0
- package/dist/door/gibs.js +362 -0
- package/dist/door/grid.d.ts +201 -0
- package/dist/door/grid.js +251 -0
- package/dist/door/index.d.ts +2 -0
- package/dist/door/index.js +2 -0
- package/dist/door/map.d.ts +5 -0
- package/dist/realistic/element-base.d.ts +6 -0
- package/dist/realistic/element-base.js +51 -7
- package/dist/realistic/index.d.ts +1 -1
- package/dist/realistic/index.js +1 -1
- package/dist/realistic/shaders.js +2 -2
- package/dist/realistic/tile-set.d.ts +11 -1
- package/dist/realistic/tile-set.js +143 -19
- package/dist/realistic/tiles.d.ts +20 -0
- package/dist/realistic/tiles.js +94 -1
- package/dist/space/element-base.d.ts +17 -0
- package/dist/space/element-base.js +45 -5
- package/dist/space/ride.js +2 -2
- package/dist/space/scene.d.ts +14 -0
- package/dist/space/scene.js +17 -5
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ uniform sampler2D paintMap;
|
|
|
35
35
|
uniform float paintNow;
|
|
36
36
|
uniform float paintSpan;
|
|
37
37
|
uniform float paintOn;
|
|
38
|
-
${tile ? "uniform vec4 nightRect;\nvarying vec2 vUvG;" : ""}
|
|
38
|
+
${tile ? "uniform vec4 nightRect;\nuniform float tileAlpha;\nvarying vec2 vUvG;" : ""}
|
|
39
39
|
varying vec2 vUv;
|
|
40
40
|
varying vec3 vNormal;
|
|
41
41
|
varying vec3 vWorld;
|
|
@@ -96,7 +96,7 @@ void main() {
|
|
|
96
96
|
col = mix(col, vec3(1.0, 0.55, 0.12), clamp(show, 0.0, 0.92));
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
gl_FragColor = vec4(col, 1.0);
|
|
99
|
+
gl_FragColor = vec4(col, ${tile ? "tileAlpha" : "1.0"});
|
|
100
100
|
}`;
|
|
101
101
|
export const SURFACE_FRAG = surfaceFrag(false);
|
|
102
102
|
/** The same surface for a map tile: the tile's own program. */
|
|
@@ -53,10 +53,14 @@ export interface TileShared {
|
|
|
53
53
|
/** More uniforms the surface program reads (the cloud picture and where the Sun is in the Earth's axes), shared with the sphere's own. */
|
|
54
54
|
extra?: Record<string, Uniform<unknown>>;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The map source each layer is drawn from now, or none: read at every draw. A layer's tiles come from its source alone, and the night tiles go with day tiles (no day source, no night tiles).
|
|
58
|
+
* `finer` is laid over the day tiles, and only when the view is closer than the day tiles serve. A source with its own `grid` is placed on that grid.
|
|
59
|
+
*/
|
|
57
60
|
export type TileSources = {
|
|
58
61
|
day?: EarthMapSource;
|
|
59
62
|
night?: EarthMapSource;
|
|
63
|
+
finer?: EarthMapSource;
|
|
60
64
|
};
|
|
61
65
|
export interface TileSetDeps {
|
|
62
66
|
assets: AssetCache;
|
|
@@ -68,6 +72,8 @@ export interface TileSetDeps {
|
|
|
68
72
|
cap: () => number;
|
|
69
73
|
/** Ask for one draw. */
|
|
70
74
|
invalidate: () => void;
|
|
75
|
+
/** A reader who asked for less motion: a finer tile is shown at once, with no fade. */
|
|
76
|
+
reducedMotion?: () => boolean;
|
|
71
77
|
/** Told once when a tile set's manifest has been read: the finest width of each layer. */
|
|
72
78
|
onManifest?: (layers: Record<string, number>) => void;
|
|
73
79
|
limit?: number;
|
|
@@ -92,6 +98,10 @@ export interface TileStats {
|
|
|
92
98
|
refused: number;
|
|
93
99
|
/** The tiles in view that came from each source, by the source's id: what a credit line counts. */
|
|
94
100
|
used: Record<string, number>;
|
|
101
|
+
/** The level of the finer grid now wanted, or `null` when the view is no closer than the tiles underneath. */
|
|
102
|
+
finer: number | null;
|
|
103
|
+
/** True while a finer tile is still fading in. At rest, after the fade, this is false and nothing is drawn for it. */
|
|
104
|
+
fading: boolean;
|
|
95
105
|
}
|
|
96
106
|
export interface TileSet {
|
|
97
107
|
sync(camera: TileCamera, sun: readonly [number, number, number], night: boolean, ratio: number): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { gridOnEarth } from "../door/grid.js";
|
|
1
2
|
import { DEFAULT_LEVELS, tileKeyParts, tilePlace } from "../door/map.js";
|
|
2
3
|
import { TILE_FRAG, TILE_VERT } from "./shaders.js";
|
|
3
4
|
import { MAX_TEXTURE, TIERS } from "./tiers.js";
|
|
4
|
-
import { coveringTile, tileColumns, tileLevel, tileRect, tileRows, tilesInView } from "./tiles.js";
|
|
5
|
+
import { coveringTile, gridTilesInView, TEXEL_SLACK, tileColumns, tileLevel, tileRect, tileRows, tilesInView } from "./tiles.js";
|
|
5
6
|
/**
|
|
6
7
|
* 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
|
*
|
|
@@ -38,6 +39,11 @@ export const TILE_KEEP_MS = 4000;
|
|
|
38
39
|
export const TILE_BUDGET = 72 * 1024 * 1024;
|
|
39
40
|
const IN_FLIGHT = 6;
|
|
40
41
|
const NEW_PER_DRAW = 8;
|
|
42
|
+
/** A finer tile fades in over this many milliseconds, then the loop stops. A reader who asked for less motion skips it. */
|
|
43
|
+
const FADE_MS = 300;
|
|
44
|
+
/** The package's own day pyramid, at level 5. A finer source is not asked until the view wants more than the tiles underneath, and never less than this when those tiles are not loaded yet. */
|
|
45
|
+
const OWN_SERVED = 32768;
|
|
46
|
+
const RAD = Math.PI / 180;
|
|
41
47
|
// the day mix reaches full light at 0.22: a tile whose darkest point is brighter than that never shows the night picture
|
|
42
48
|
const NIGHT_BELOW = 0.25;
|
|
43
49
|
const GRID = 16;
|
|
@@ -108,6 +114,10 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
108
114
|
const failed = new Map();
|
|
109
115
|
let queue = [];
|
|
110
116
|
let wantedKeys = new Set();
|
|
117
|
+
/** Grid tiles in view this frame, by the key the source named. */
|
|
118
|
+
let gridSeen = new Set();
|
|
119
|
+
let finerLevel = null;
|
|
120
|
+
let fading = false;
|
|
111
121
|
/** The sources the levels were read for. */
|
|
112
122
|
let current = {};
|
|
113
123
|
/** Counts the times the sources changed: an answer for an earlier set of them is let go. */
|
|
@@ -126,8 +136,9 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
126
136
|
let disposed = false;
|
|
127
137
|
const baseDay = TIERS.day[TIERS.day.length - 1];
|
|
128
138
|
const baseNight = TIERS.night[TIERS.night.length - 1];
|
|
139
|
+
const reduced = () => (deps.reducedMotion ?? (() => typeof globalThis.matchMedia === "function" && globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches))();
|
|
129
140
|
const accountOf = (source, key) => `chikyu-earth:tile:${tagOf(source)}:${key}`;
|
|
130
|
-
const take = (layer, id, source) => deps.assets.acquire(accountOf(source, keyOf(layer, id)), () => {
|
|
141
|
+
const take = (layer, id, source, knownKey) => deps.assets.acquire(accountOf(source, knownKey ?? keyOf(layer === "finer" ? "day" : layer, id)), () => {
|
|
131
142
|
const texture = new three.Texture();
|
|
132
143
|
texture.wrapS = three.ClampToEdgeWrapping;
|
|
133
144
|
texture.wrapT = three.ClampToEdgeWrapping;
|
|
@@ -139,7 +150,7 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
139
150
|
made.ready = Promise.resolve()
|
|
140
151
|
.then(() => {
|
|
141
152
|
// the source names its tiles: the one for this place is the key of the pyramid's tile that matches
|
|
142
|
-
const key = source.need({ ...tilePlace(id), layer }, 1024 * 2 ** id.level).find((one) => {
|
|
153
|
+
const key = knownKey ?? source.need({ ...tilePlace(id), layer: layer === "finer" ? "day" : layer }, 1024 * 2 ** id.level).find((one) => {
|
|
143
154
|
const parts = tileKeyParts(one);
|
|
144
155
|
return parts !== undefined && parts.level === id.level && parts.col === id.col && parts.row === id.row;
|
|
145
156
|
});
|
|
@@ -237,13 +248,13 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
237
248
|
const pump = () => {
|
|
238
249
|
while (inFlight < IN_FLIGHT && queue.length > 0) {
|
|
239
250
|
const next = queue.shift();
|
|
240
|
-
const key =
|
|
251
|
+
const key = next.key;
|
|
241
252
|
if (entries.has(key))
|
|
242
253
|
continue;
|
|
243
|
-
const source = current[next.layer];
|
|
254
|
+
const source = next.layer === "finer" ? current.finer : current[next.layer];
|
|
244
255
|
if (source === undefined)
|
|
245
256
|
continue;
|
|
246
|
-
const entry = { key, layer: next.layer, id: next.id, source, asset: take(next.layer, next.id, source), ready: false, integrated: false, lastWanted: clock() };
|
|
257
|
+
const entry = { key, layer: next.layer, id: next.id, source, ...(next.grid ? { gridLevel: next.grid } : {}), asset: take(next.layer, next.id, source, next.grid ? key : undefined), ready: false, integrated: false, lastWanted: clock() };
|
|
247
258
|
entries.set(key, entry);
|
|
248
259
|
inFlight += 1;
|
|
249
260
|
requested += 1;
|
|
@@ -314,9 +325,18 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
314
325
|
}
|
|
315
326
|
return { level: null, day: [], night: [] };
|
|
316
327
|
};
|
|
328
|
+
const gridRect = (entry) => {
|
|
329
|
+
const grid = entry.source.grid;
|
|
330
|
+
const level = entry.gridLevel;
|
|
331
|
+
if (!grid || !level)
|
|
332
|
+
return tileRect(entry.id);
|
|
333
|
+
const span = gridOnEarth(level, entry.id.col, entry.id.row, grid.extent) ?? { lonMin: -180, lonMax: 180, latMin: -90, latMax: 90 };
|
|
334
|
+
return [span.lonMin * RAD, span.latMax * RAD, span.lonMax * RAD, span.latMin * RAD];
|
|
335
|
+
};
|
|
317
336
|
const makeMesh = (entry) => {
|
|
318
337
|
const nightRect = { value: [0, 0, 1, 1] };
|
|
319
338
|
const nightMap = { value: shared.night.value };
|
|
339
|
+
const cover = { value: 1 };
|
|
320
340
|
const material = new three.ShaderMaterial({
|
|
321
341
|
vertexShader: TILE_VERT,
|
|
322
342
|
fragmentShader: TILE_FRAG,
|
|
@@ -330,14 +350,18 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
330
350
|
ortho: shared.ortho,
|
|
331
351
|
...shared.extra,
|
|
332
352
|
nightRect,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
353
|
+
tileAlpha: cover,
|
|
354
|
+
rect: { value: gridRect(entry) },
|
|
355
|
+
// a finer level sits a little higher, so two levels at once never fight for the same depth; a grid tile sits above the package's finest. All sit above the whole-Earth sphere's flat faces
|
|
356
|
+
radius: { value: entry.gridLevel ? 1.0008 : 1.0004 + 0.0001 * (entry.id.level - 3) },
|
|
336
357
|
},
|
|
337
358
|
polygonOffset: true,
|
|
338
359
|
polygonOffsetFactor: -1,
|
|
339
360
|
polygonOffsetUnits: -1,
|
|
361
|
+
transparent: false,
|
|
362
|
+
depthWrite: true,
|
|
340
363
|
});
|
|
364
|
+
entry.cover = cover;
|
|
341
365
|
const mesh = new three.Mesh(geometry, material);
|
|
342
366
|
mesh.frustumCulled = false;
|
|
343
367
|
mesh.visible = false;
|
|
@@ -350,7 +374,7 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
350
374
|
const retarget = () => {
|
|
351
375
|
const night = nightLevels();
|
|
352
376
|
for (const entry of entries.values()) {
|
|
353
|
-
if (!entry.mesh || !entry.nightMap || !entry.nightRect)
|
|
377
|
+
if (!entry.mesh || !entry.nightMap || !entry.nightRect || entry.gridLevel)
|
|
354
378
|
continue;
|
|
355
379
|
let texture = null;
|
|
356
380
|
let rect = [0, 0, 1, 1];
|
|
@@ -380,6 +404,14 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
380
404
|
for (const entry of entries.values()) {
|
|
381
405
|
if (!entry.mesh)
|
|
382
406
|
continue;
|
|
407
|
+
if (entry.gridLevel) {
|
|
408
|
+
entry.mesh.visible = gridSeen.has(entry.key);
|
|
409
|
+
if (entry.mesh.visible) {
|
|
410
|
+
shown += 1;
|
|
411
|
+
used.set(entry.source.info.id, (used.get(entry.source.info.id) ?? 0) + 1);
|
|
412
|
+
}
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
383
415
|
let set = visible.get(entry.id.level);
|
|
384
416
|
if (!set) {
|
|
385
417
|
set = new Set(tilesInView(entry.id.level, camera).map((tile) => tile.row * tileColumns(tile.level) + tile.col));
|
|
@@ -444,25 +476,89 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
444
476
|
heldBytes: heldBytes(),
|
|
445
477
|
refused,
|
|
446
478
|
used: Object.fromEntries(used),
|
|
479
|
+
finer: finerLevel,
|
|
480
|
+
fading,
|
|
447
481
|
};
|
|
448
482
|
},
|
|
449
483
|
sync(camera, sun, night, ratio) {
|
|
450
484
|
if (disposed)
|
|
451
485
|
return;
|
|
452
486
|
const now = deps.sources();
|
|
453
|
-
if (now.day !== current.day || now.night !== current.night) {
|
|
487
|
+
if (now.day !== current.day || now.night !== current.night || now.finer !== current.finer) {
|
|
454
488
|
reset();
|
|
455
|
-
current = { ...(now.day ? { day: now.day } : {}), ...(now.night ? { night: now.night } : {}) };
|
|
456
|
-
if (current.day !== undefined)
|
|
489
|
+
current = { ...(now.day ? { day: now.day } : {}), ...(now.night ? { night: now.night } : {}), ...(now.finer ? { finer: now.finer } : {}) };
|
|
490
|
+
if (current.day !== undefined && !current.day.grid)
|
|
457
491
|
readManifest(current);
|
|
492
|
+
else if (current.day?.grid)
|
|
493
|
+
manifest = { layers: {} };
|
|
458
494
|
}
|
|
459
495
|
last = { camera };
|
|
460
|
-
|
|
496
|
+
const pyramidReady = current.day !== undefined && !current.day.grid && manifest != null && manifest.layers["day"] !== undefined;
|
|
497
|
+
if (current.day === undefined && current.finer === undefined)
|
|
498
|
+
return;
|
|
499
|
+
if (current.day !== undefined && !current.day.grid && manifest === undefined && current.finer === undefined)
|
|
461
500
|
return;
|
|
462
501
|
const at = clock();
|
|
463
|
-
const wanted = choose(camera, sun, night, ratio);
|
|
502
|
+
const wanted = pyramidReady ? choose(camera, sun, night, ratio) : { level: null, day: [], night: [] };
|
|
464
503
|
wantedLevel = wanted.level;
|
|
465
|
-
|
|
504
|
+
const needed = (2 * Math.PI * camera.radius * ratio) / TEXEL_SLACK;
|
|
505
|
+
const served = () => {
|
|
506
|
+
if (current.day?.grid)
|
|
507
|
+
return Math.max(...current.day.grid.levels.map((level) => level.width));
|
|
508
|
+
if (current.day === undefined)
|
|
509
|
+
return OWN_SERVED;
|
|
510
|
+
if (manifest === undefined)
|
|
511
|
+
return undefined;
|
|
512
|
+
const widths = manifest?.layers["day"]?.levels.map((level) => level.width) ?? [];
|
|
513
|
+
return widths.length > 0 ? Math.max(...widths) : OWN_SERVED;
|
|
514
|
+
};
|
|
515
|
+
const jobs = [];
|
|
516
|
+
const addGrid = (source, layer, minWidth, taken) => {
|
|
517
|
+
const grid = source.grid;
|
|
518
|
+
if (!grid)
|
|
519
|
+
return null;
|
|
520
|
+
const levels = grid.levels.filter((level) => level.width > minWidth).sort((a, b) => a.width - b.width);
|
|
521
|
+
if (levels.length === 0 || !(needed > minWidth))
|
|
522
|
+
return null;
|
|
523
|
+
let index = levels.findIndex((level) => level.width >= needed);
|
|
524
|
+
if (index < 0)
|
|
525
|
+
index = levels.length - 1;
|
|
526
|
+
while (index >= 0) {
|
|
527
|
+
const level = levels[index];
|
|
528
|
+
const tiles = gridTilesInView(level, grid.extent, camera, sun);
|
|
529
|
+
if (taken + tiles.length <= limit) {
|
|
530
|
+
for (const tile of tiles) {
|
|
531
|
+
const place = gridOnEarth(level, tile.col, tile.row, grid.extent);
|
|
532
|
+
if (!place)
|
|
533
|
+
continue;
|
|
534
|
+
const inset = {
|
|
535
|
+
lonMin: place.lonMin + (place.lonMax - place.lonMin) * 0.25,
|
|
536
|
+
lonMax: place.lonMax - (place.lonMax - place.lonMin) * 0.25,
|
|
537
|
+
latMin: place.latMin + (place.latMax - place.latMin) * 0.25,
|
|
538
|
+
latMax: place.latMax - (place.latMax - place.latMin) * 0.25,
|
|
539
|
+
layer: "day",
|
|
540
|
+
};
|
|
541
|
+
const key = source.need(inset, level.width).find((one) => {
|
|
542
|
+
const parts = tileKeyParts(one);
|
|
543
|
+
return parts !== undefined && parts.level === tile.level && parts.col === tile.col && parts.row === tile.row;
|
|
544
|
+
});
|
|
545
|
+
if (key)
|
|
546
|
+
jobs.push({ layer, id: { level: tile.level, col: tile.col, row: tile.row }, key, grid: level });
|
|
547
|
+
}
|
|
548
|
+
return level.level;
|
|
549
|
+
}
|
|
550
|
+
index -= 1;
|
|
551
|
+
}
|
|
552
|
+
return null;
|
|
553
|
+
};
|
|
554
|
+
finerLevel = null;
|
|
555
|
+
if (current.day?.grid)
|
|
556
|
+
wantedLevel = addGrid(current.day, "day", baseDay, 0);
|
|
557
|
+
const floor = served();
|
|
558
|
+
if (current.finer?.grid && floor !== undefined)
|
|
559
|
+
finerLevel = addGrid(current.finer, "finer", floor, wanted.day.length + wanted.night.length + jobs.length);
|
|
560
|
+
gridSeen = new Set(jobs.map((job) => job.key));
|
|
561
|
+
wantedKeys = new Set([...wanted.day.map((tile) => keyOf("day", tile)), ...wanted.night.map((id) => keyOf("night", id)), ...jobs.map((job) => job.key)]);
|
|
466
562
|
// a tile that failed is asked for again only after it has left the view and come back (the view changed), never on a timer and never while it stays in view: at rest the door sends nothing
|
|
467
563
|
for (const key of [...failed.keys()])
|
|
468
564
|
if (!wantedKeys.has(key))
|
|
@@ -472,7 +568,11 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
472
568
|
if (entry)
|
|
473
569
|
entry.lastWanted = at;
|
|
474
570
|
}
|
|
475
|
-
queue = [
|
|
571
|
+
queue = [
|
|
572
|
+
...wanted.day.map((tile) => ({ layer: "day", id: { level: tile.level, col: tile.col, row: tile.row }, key: keyOf("day", tile) })),
|
|
573
|
+
...wanted.night.map((id) => ({ layer: "night", id, key: keyOf("night", id) })),
|
|
574
|
+
...jobs.map((job) => ({ layer: job.layer, id: job.id, key: job.key, grid: job.grid })),
|
|
575
|
+
].filter((item) => !failed.has(item.key) && !entries.has(item.key));
|
|
476
576
|
pump();
|
|
477
577
|
let fresh = 0;
|
|
478
578
|
let waiting = false;
|
|
@@ -485,8 +585,18 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
485
585
|
}
|
|
486
586
|
fresh += 1;
|
|
487
587
|
entry.integrated = true;
|
|
488
|
-
if (entry.layer === "day")
|
|
588
|
+
if (entry.layer === "day" || entry.layer === "finer")
|
|
489
589
|
makeMesh(entry);
|
|
590
|
+
if (entry.gridLevel && entry.cover) {
|
|
591
|
+
entry.born = at;
|
|
592
|
+
const full = reduced();
|
|
593
|
+
entry.cover.value = full ? 1 : 0;
|
|
594
|
+
const material = entry.mesh?.material;
|
|
595
|
+
if (material && !full) {
|
|
596
|
+
material.transparent = true;
|
|
597
|
+
material.depthWrite = false;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
490
600
|
}
|
|
491
601
|
sweep();
|
|
492
602
|
retarget();
|
|
@@ -494,7 +604,21 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
494
604
|
if (wanted.level !== null)
|
|
495
605
|
visible.set(wanted.level, new Set(wanted.day.map((tile) => tile.row * tileColumns(tile.level) + tile.col)));
|
|
496
606
|
place(camera, visible);
|
|
497
|
-
|
|
607
|
+
fading = false;
|
|
608
|
+
for (const entry of entries.values()) {
|
|
609
|
+
if (!entry.gridLevel || !entry.cover || !entry.integrated)
|
|
610
|
+
continue;
|
|
611
|
+
const t = reduced() ? 1 : Math.min(1, (clock() - (entry.born ?? at)) / FADE_MS);
|
|
612
|
+
entry.cover.value = t;
|
|
613
|
+
const material = entry.mesh?.material;
|
|
614
|
+
if (material) {
|
|
615
|
+
material.transparent = t < 1;
|
|
616
|
+
material.depthWrite = t >= 1;
|
|
617
|
+
}
|
|
618
|
+
if (t < 1)
|
|
619
|
+
fading = true;
|
|
620
|
+
}
|
|
621
|
+
if (waiting || fading)
|
|
498
622
|
deps.invalidate();
|
|
499
623
|
arm();
|
|
500
624
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MapGrid, type MapGridLevel } from "../door/grid.ts";
|
|
1
2
|
/**
|
|
2
3
|
* One tile of the map pyramid: a level, a column counted east from longitude -180 and a row counted south from latitude 90.
|
|
3
4
|
*
|
|
@@ -233,3 +234,22 @@ export declare function parseManifest(json: unknown): {
|
|
|
233
234
|
tileSize: number;
|
|
234
235
|
layers: Record<string, TileLayer>;
|
|
235
236
|
} | undefined;
|
|
237
|
+
/**
|
|
238
|
+
* The tiles of one level of a source's own grid that are in view. Only the columns and rows under the box are tested, so a fine matrix (hundreds of columns) is not walked. A tile that misses the Earth is left out.
|
|
239
|
+
*
|
|
240
|
+
* @param level - A level of the source's grid.
|
|
241
|
+
* @param extent - The Earth's extent, from the same grid.
|
|
242
|
+
* @param camera - The camera.
|
|
243
|
+
* @param sun - The Sun's direction as the camera sees it, for each tile's `ndl`; left out, `ndl` is 1.
|
|
244
|
+
* @returns The tiles in view, the nearest to the middle of the box first.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* import { gibsGrid } from "@johnmorrisdotca/chikyu-earth/door";
|
|
249
|
+
* import { gridTilesInView } from "@johnmorrisdotca/chikyu-earth/realistic";
|
|
250
|
+
*
|
|
251
|
+
* const grid = gibsGrid("250m");
|
|
252
|
+
* console.log(gridTilesInView(grid.levels[6]!, grid.extent, { lon: 0, lat: 0, width: 800, height: 600, panX: 0, panY: 0, radius: 8000 }).length > 0);
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
export declare function gridTilesInView(level: MapGridLevel, extent: MapGrid["extent"], camera: TileCamera, sun?: readonly [number, number, number]): VisibleTile[];
|
package/dist/realistic/tiles.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The maths of the Earth's map tiles, with no browser and no three.js: which pyramid level a zoom needs, and which tiles of that level are in view. Pure.
|
|
2
2
|
//
|
|
3
3
|
// A tile set is the map cut into 512 pixel squares: level L is `1024 * 2^L` pixels across, in `2^(L+1)` columns and `2^L` rows, column 0 at longitude -180 and row 0 at
|
|
4
|
-
// latitude 90, a tile at `<layer>/<level>/<column>/<row>.webp` (`scripts/make-earth-tiles.py` makes one).
|
|
4
|
+
// latitude 90, a tile at `<layer>/<level>/<column>/<row>.webp` (`scripts/make-earth-tiles.py` makes one). A source may declare a different grid; `gridTilesInView` walks only the columns and rows the view can see.
|
|
5
|
+
import { gridOnEarth, gridSpan, gridTileAt } from "../door/grid.js";
|
|
5
6
|
const RAD = Math.PI / 180;
|
|
6
7
|
/**
|
|
7
8
|
* How much larger than a device pixel a map texel may be before the next level is wanted: 1.25 is a quarter larger.
|
|
@@ -282,3 +283,95 @@ export function parseManifest(json) {
|
|
|
282
283
|
}
|
|
283
284
|
return Object.keys(layers).length > 0 ? { tileSize: 512, layers } : undefined;
|
|
284
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* The tiles of one level of a source's own grid that are in view. Only the columns and rows under the box are tested, so a fine matrix (hundreds of columns) is not walked. A tile that misses the Earth is left out.
|
|
288
|
+
*
|
|
289
|
+
* @param level - A level of the source's grid.
|
|
290
|
+
* @param extent - The Earth's extent, from the same grid.
|
|
291
|
+
* @param camera - The camera.
|
|
292
|
+
* @param sun - The Sun's direction as the camera sees it, for each tile's `ndl`; left out, `ndl` is 1.
|
|
293
|
+
* @returns The tiles in view, the nearest to the middle of the box first.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* import { gibsGrid } from "@johnmorrisdotca/chikyu-earth/door";
|
|
298
|
+
* import { gridTilesInView } from "@johnmorrisdotca/chikyu-earth/realistic";
|
|
299
|
+
*
|
|
300
|
+
* const grid = gibsGrid("250m");
|
|
301
|
+
* console.log(gridTilesInView(grid.levels[6]!, grid.extent, { lon: 0, lat: 0, width: 800, height: 600, panX: 0, panY: 0, radius: 8000 }).length > 0);
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export function gridTilesInView(level, extent, camera, sun) {
|
|
305
|
+
const lonRad = camera.lon * RAD;
|
|
306
|
+
const latRad = camera.lat * RAD;
|
|
307
|
+
const look = camera.perspective;
|
|
308
|
+
const margin = Math.min(160, Math.min(camera.width, camera.height) / 4);
|
|
309
|
+
const cx = camera.width / 2 + camera.panX;
|
|
310
|
+
const cy = camera.height / 2 + camera.panY;
|
|
311
|
+
const eyeLength = look ? Math.hypot(...look.eye) : 1;
|
|
312
|
+
const ndlOf = (z) => (sun ? z[0] * sun[0] + z[1] * sun[1] + z[2] * sun[2] : 1);
|
|
313
|
+
const sample = (lon, lat) => {
|
|
314
|
+
if (!look) {
|
|
315
|
+
const n = turned(lon * RAD, lat * RAD, lonRad, latRad);
|
|
316
|
+
const at = { x: cx + n[0] * camera.radius, y: cy - n[1] * camera.radius };
|
|
317
|
+
return { n, screen: n[2] < 0 ? null : at, flat: at, toward: n[2] };
|
|
318
|
+
}
|
|
319
|
+
const cl = Math.cos(lat * RAD);
|
|
320
|
+
const n = [cl * Math.sin(lon * RAD), Math.sin(lat * RAD), cl * Math.cos(lon * RAD)];
|
|
321
|
+
const along = n[0] * look.eye[0] + n[1] * look.eye[1] + n[2] * look.eye[2];
|
|
322
|
+
const screen = along < 1 ? null : look.project(n);
|
|
323
|
+
return { n, screen, flat: screen, toward: along / eyeLength };
|
|
324
|
+
};
|
|
325
|
+
const candidates = new Set();
|
|
326
|
+
const step = 24;
|
|
327
|
+
for (let y = 0; y <= camera.height + step - 1; y += step) {
|
|
328
|
+
for (let x = 0; x <= camera.width + step - 1; x += step) {
|
|
329
|
+
const place = pointOnEarth(camera, Math.min(x, camera.width), Math.min(y, camera.height));
|
|
330
|
+
if (!place)
|
|
331
|
+
continue;
|
|
332
|
+
const at = gridTileAt(level, place.lon, place.lat, extent);
|
|
333
|
+
if (!at)
|
|
334
|
+
continue;
|
|
335
|
+
for (let dr = -1; dr <= 1; dr += 1) {
|
|
336
|
+
for (let dc = -1; dc <= 1; dc += 1) {
|
|
337
|
+
const col = at.col + dc;
|
|
338
|
+
const row = at.row + dr;
|
|
339
|
+
if (col < 0 || row < 0 || col >= level.columns || row >= level.rows)
|
|
340
|
+
continue;
|
|
341
|
+
if (!gridOnEarth(level, col, row, extent))
|
|
342
|
+
continue;
|
|
343
|
+
candidates.add(row * level.columns + col);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const found = [];
|
|
349
|
+
for (const key of candidates) {
|
|
350
|
+
const col = key % level.columns;
|
|
351
|
+
const row = Math.floor(key / level.columns);
|
|
352
|
+
const span = gridSpan(level, col, row);
|
|
353
|
+
const west = Math.max(span.lonMin, extent.west);
|
|
354
|
+
const east = Math.min(span.lonMax, extent.east);
|
|
355
|
+
const north = Math.min(span.latMax, extent.north);
|
|
356
|
+
const south = Math.max(span.latMin, extent.south);
|
|
357
|
+
const middle = sample((west + east) / 2, (north + south) / 2);
|
|
358
|
+
if (middle.toward < -0.4)
|
|
359
|
+
continue;
|
|
360
|
+
let inside = false;
|
|
361
|
+
let darkest = 1;
|
|
362
|
+
for (let j = 0; j <= 2; j += 1) {
|
|
363
|
+
for (let i = 0; i <= 2; i += 1) {
|
|
364
|
+
const p = sample(west + ((east - west) * i) / 2, north + ((south - north) * j) / 2);
|
|
365
|
+
darkest = Math.min(darkest, ndlOf(p.n));
|
|
366
|
+
if (p.screen && p.screen.x >= -margin && p.screen.x <= camera.width + margin && p.screen.y >= -margin && p.screen.y <= camera.height + margin)
|
|
367
|
+
inside = true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!inside)
|
|
371
|
+
continue;
|
|
372
|
+
const d = middle.flat ? Math.hypot(middle.flat.x - camera.width / 2, middle.flat.y - camera.height / 2) : Math.hypot(camera.width, camera.height);
|
|
373
|
+
found.push({ level: level.level, col, row, d, ndl: darkest });
|
|
374
|
+
}
|
|
375
|
+
found.sort((a, b) => a.d - b.d);
|
|
376
|
+
return found;
|
|
377
|
+
}
|
|
@@ -210,6 +210,11 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
210
210
|
/** Where the finer map tiles are served from (a folder with `manifest.json`), or `null` for none; the attribute `tiles`. The Earth lays only the tiles in view over its own picture, at the level the camera's height needs, so a ride a few hundred kilometres above the ground sees sharp ground. */
|
|
211
211
|
get tiles(): string | null;
|
|
212
212
|
set tiles(value: string | null);
|
|
213
|
+
/**
|
|
214
|
+
* Finer imagery than the package's own tiles, read by the browser from NASA's imagery service. `gibs` turns it on. See `<chikyu-earth-realistic>` for the layer and the day.
|
|
215
|
+
*/
|
|
216
|
+
get tilesFiner(): string | null;
|
|
217
|
+
set tilesFiner(value: string | null);
|
|
213
218
|
/**
|
|
214
219
|
* True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape (the Earth fits the shorter side with its glow inside it, `earth-size`), a plain wheel zooms instead of scrolling
|
|
215
220
|
* the page, a drag anywhere on it turns the view, and a touch drag turns it instead of scrolling. A notch of the wheel is about 1.2 times; out far enough the Moon, the Sun and the planets come into view.
|
|
@@ -684,6 +689,18 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
684
689
|
y: number;
|
|
685
690
|
shown: boolean;
|
|
686
691
|
parts: number;
|
|
692
|
+
radiusPx: number;
|
|
693
|
+
box: {
|
|
694
|
+
left: number;
|
|
695
|
+
top: number;
|
|
696
|
+
right: number;
|
|
697
|
+
bottom: number;
|
|
698
|
+
};
|
|
699
|
+
axes: {
|
|
700
|
+
x: readonly number[];
|
|
701
|
+
y: readonly number[];
|
|
702
|
+
z: readonly number[];
|
|
703
|
+
};
|
|
687
704
|
} | null;
|
|
688
705
|
/** The finer map tiles (`tiles`): the level wanted now (`null` while the package's own pictures are sharp enough), the tiles held and shown, and the fetches made. */
|
|
689
706
|
tiles: TileStats;
|
|
@@ -20,6 +20,7 @@ import { COUNTRY_NAMES_STYLE, createCountryHost } from "../country-names/host.js
|
|
|
20
20
|
import { SEA_NAMES_ATTRIBUTES, readSeaNames } from "../sea-names/geometry.js";
|
|
21
21
|
import { SEA_NAMES_STYLE, createSeaHost } from "../sea-names/host.js";
|
|
22
22
|
import { createGate, frameCap } from "../realistic/gate.js";
|
|
23
|
+
import { createFinerHolder, GIBS_CREDIT, GIBS_ID } from "../door/gibs.js";
|
|
23
24
|
import { folderSource } from "../door/map.js";
|
|
24
25
|
import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
|
|
25
26
|
import { NOTES_STYLE, setAirNote } from "../realistic/air-note.js";
|
|
@@ -156,8 +157,11 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
156
157
|
* ```
|
|
157
158
|
*/
|
|
158
159
|
export class ChikyuSpace extends HTMLElement {
|
|
159
|
-
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "ride-viewpoint"];
|
|
160
|
+
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "ride-viewpoint"];
|
|
160
161
|
#model = newSpaceModel();
|
|
162
|
+
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
163
|
+
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
164
|
+
#finerNote;
|
|
161
165
|
#paint = createPaintState();
|
|
162
166
|
#mode = "now";
|
|
163
167
|
#speed = 1;
|
|
@@ -244,13 +248,14 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
244
248
|
if (!this.hasAttribute("aria-label"))
|
|
245
249
|
this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
|
|
246
250
|
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
247
|
-
root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p><p id="bodies-note" hidden></p></div>`;
|
|
251
|
+
root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p><p id="bodies-note" hidden></p><p id="finer-credit" hidden></p></div>`;
|
|
248
252
|
adoptStyles(root, STYLE, this.nonce);
|
|
249
253
|
this.#stage = root.getElementById("stage");
|
|
250
254
|
this.#labelBox = root.getElementById("labels");
|
|
251
255
|
this.#note = root.getElementById("meteor-note");
|
|
252
256
|
this.#airNote = root.getElementById("air-note");
|
|
253
257
|
this.#bodiesNote = root.getElementById("bodies-note");
|
|
258
|
+
this.#finerNote = root.getElementById("finer-credit");
|
|
254
259
|
this.#sky = createSkyHost({
|
|
255
260
|
root,
|
|
256
261
|
attribute: (name) => this.getAttribute(name),
|
|
@@ -347,6 +352,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
347
352
|
onPainterError: (error) => this.dispatchEvent(new CustomEvent("chikyu-bodies-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
348
353
|
sources: () => this.#tileSources(),
|
|
349
354
|
onTiles: (layers) => this.dispatchEvent(new CustomEvent("chikyu-tiles", { detail: { layers } })),
|
|
355
|
+
onTilesDrawn: () => this.#showFinerCredit(),
|
|
350
356
|
});
|
|
351
357
|
this.#view = taken.renderer.view(this.#stage, item, { still: null });
|
|
352
358
|
this.#set("loading");
|
|
@@ -503,18 +509,35 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
503
509
|
this.#model.satellites.streakMax = readStreakMax(value);
|
|
504
510
|
this.#gate?.request();
|
|
505
511
|
}
|
|
506
|
-
else if (name === "tiles")
|
|
512
|
+
else if (name === "tiles" || name === "tiles-finer" || name === "tiles-finer-layer" || name === "tiles-finer-date")
|
|
507
513
|
this.#gate?.request();
|
|
508
514
|
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
509
515
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
510
516
|
if (name === "bodies-credit" || name === "lang")
|
|
511
517
|
this.#showBodiesCredit();
|
|
518
|
+
if (name === "lang")
|
|
519
|
+
this.#showFinerCredit();
|
|
512
520
|
}
|
|
513
521
|
#wheel = (event) => immersiveWheel(this, event);
|
|
514
522
|
/** The map source of each layer now: the folder of the `tiles` attribute, or none. */
|
|
523
|
+
#showFinerCredit() {
|
|
524
|
+
const note = this.#finerNote;
|
|
525
|
+
if (!note)
|
|
526
|
+
return;
|
|
527
|
+
const count = this.#model.tiles?.stats.used[GIBS_ID] ?? 0;
|
|
528
|
+
const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
|
|
529
|
+
const text = count > 0 ? GIBS_CREDIT[lang] : "";
|
|
530
|
+
if (note.textContent !== text)
|
|
531
|
+
note.textContent = text;
|
|
532
|
+
if (note.lang !== lang)
|
|
533
|
+
note.lang = lang;
|
|
534
|
+
if (note.hidden !== (text === ""))
|
|
535
|
+
note.hidden = text === "";
|
|
536
|
+
}
|
|
515
537
|
#tileSources() {
|
|
516
538
|
const folder = this.tiles === null ? undefined : folderSource(this.tiles);
|
|
517
|
-
|
|
539
|
+
const finer = this.#finerHold.source((attr) => this.getAttribute(attr), false);
|
|
540
|
+
return { ...(folder ? { day: folder, night: folder } : {}), ...(finer ? { finer } : {}) };
|
|
518
541
|
}
|
|
519
542
|
/** Where the finer map tiles are served from (a folder with `manifest.json`), or `null` for none; the attribute `tiles`. The Earth lays only the tiles in view over its own picture, at the level the camera's height needs, so a ride a few hundred kilometres above the ground sees sharp ground. */
|
|
520
543
|
get tiles() {
|
|
@@ -529,6 +552,18 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
529
552
|
else
|
|
530
553
|
this.setAttribute("tiles", value);
|
|
531
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Finer imagery than the package's own tiles, read by the browser from NASA's imagery service. `gibs` turns it on. See `<chikyu-earth-realistic>` for the layer and the day.
|
|
557
|
+
*/
|
|
558
|
+
get tilesFiner() {
|
|
559
|
+
return this.getAttribute("tiles-finer") === "gibs" ? "gibs" : null;
|
|
560
|
+
}
|
|
561
|
+
set tilesFiner(value) {
|
|
562
|
+
if (value === "gibs")
|
|
563
|
+
this.setAttribute("tiles-finer", "gibs");
|
|
564
|
+
else
|
|
565
|
+
this.removeAttribute("tiles-finer");
|
|
566
|
+
}
|
|
532
567
|
/** The body painter's credit under the picture, in the element's or the page's language: shown while the painter draws the bodies (not `plain`), unless `bodies-credit` is `off`. */
|
|
533
568
|
/** The painter's credit as last told to the page (`chikyu-bodies-credit`): both languages, or empty for none. */
|
|
534
569
|
#creditKey = "";
|
|
@@ -1637,6 +1672,11 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1637
1672
|
#showMarks(marks) {
|
|
1638
1673
|
if (marks.length > 0)
|
|
1639
1674
|
this.#prepareSatLabelLang();
|
|
1675
|
+
// a satellite ridden from outside is drawn as its model: a ring and a name on it would cover the model (MODULES-1303)
|
|
1676
|
+
const ride = this.#model.ride;
|
|
1677
|
+
const ridden = ride && ride.viewpoint === "outside" && typeof ride.target !== "string" ? ride.target : null;
|
|
1678
|
+
if (ridden)
|
|
1679
|
+
marks = marks.filter((m) => !(m.ref.group === ridden.group && m.ref.index === ridden.index));
|
|
1640
1680
|
this.#marks = marks.map((m) => ({ id: `${m.ref.group}:${m.ref.index}`, label: this.#satelliteName(m.ref), x: m.x, y: m.y, visible: m.visible }));
|
|
1641
1681
|
const now = new Map();
|
|
1642
1682
|
for (const m of marks) {
|
|
@@ -1724,7 +1764,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1724
1764
|
bodyLabel: { on: this.#model.bodyLabel.settings !== null, text: this.#model.bodyLabel.text, ...this.#model.bodyLabel.drawn },
|
|
1725
1765
|
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, pick: null, hover: null, constellations: 0, culture: "iau", renders: 0, lang: "", stars: [] },
|
|
1726
1766
|
followModel: this.#model.followModel,
|
|
1727
|
-
tiles: this.#model.tiles?.stats ?? { ready: false, level: null, held: 0, shown: 0, loading: 0, failed: 0, requested: 0, heldBytes: 0, refused: 0, used: {} },
|
|
1767
|
+
tiles: this.#model.tiles?.stats ?? { ready: false, level: null, held: 0, shown: 0, loading: 0, failed: 0, requested: 0, heldBytes: 0, refused: 0, used: {}, finer: null, fading: false },
|
|
1728
1768
|
places: { ...(this.#placeLayer?.stats ?? { places: 0, shown: 0, labels: 0, renders: 0, rings: 0, satelliteNames: 0, marks: 0, groups: 0, sprites: 0, dots: 0, omitted: 0 }) },
|
|
1729
1769
|
hereCity: this.#here?.stats ?? { on: false, maxKm: 0, loaded: false, pending: false },
|
|
1730
1770
|
cityNames: this.#cities?.stats ?? { on: false, max: 0, radius: 0, tiers: [], cities: 0, names: 0, renders: 0 },
|
package/dist/space/ride.js
CHANGED
|
@@ -132,8 +132,8 @@ const unit = (a) => {
|
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
export const OUTSIDE_KM = 25;
|
|
135
|
-
/** How far below the middle of the picture the satellite is drawn in an outside ride that looks along the way it goes, as a share of half the picture's height (0.
|
|
136
|
-
const OUTSIDE_LOW = 0.
|
|
135
|
+
/** How far below the middle of the picture the satellite's middle is drawn in an outside ride that looks along the way it goes, as a share of half the picture's height (0.8: at 90 per cent of the height, so with the model drawn 17 per cent of the height in radius it crosses the bottom edge). */
|
|
136
|
+
const OUTSIDE_LOW = 0.8;
|
|
137
137
|
/**
|
|
138
138
|
* The camera of an outside ride: the pose `ridePose` works out for a camera at the satellite, moved to `OUTSIDE_KM` back along its own line of sight so the satellite is in front of it. Looking along the way it goes (`look: "horizon"`) the satellite sits a little below the middle of the picture, so the camera is behind and above it; looking
|
|
139
139
|
* down (`look: "down"`) it is at the middle, with the camera straight above it. Where the satellite sits in the picture does not change with the zoom. Which way the camera looks and which way is up are the pose's own, so the look-around is the same as from the satellite itself; the camera goes round the satellite as it looks about. Pure. Never nearer the ground than half the satellite's height.
|