@johnmorrisdotca/chikyu-earth 0.50.0 → 0.51.1
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 +16 -0
- package/README.md +1 -1
- package/dist/realistic/element-base.d.ts +1 -0
- package/dist/realistic/element-base.js +1 -1
- package/dist/space/element-base.d.ts +1 -0
- package/dist/space/element-base.js +1 -1
- package/dist/space/index.d.ts +1 -0
- package/dist/space/index.js +1 -0
- package/dist/space/path-ribbons.d.ts +13 -0
- package/dist/space/path-ribbons.js +38 -4
- package/dist/space/satellite-layer.d.ts +1 -0
- package/dist/space/satellite-layer.js +64 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.51.1 - 2026-11-13
|
|
4
|
+
|
|
5
|
+
Tests only: the package is unchanged by this release.
|
|
6
|
+
|
|
7
|
+
- **The ride spec's lost-context test no longer runs out of time** (MODULES-1191). "A lost context comes back with the ride" was the tail of a test of three rounds of six ride switches that takes half of its 60 seconds on its own; it is now a test of its own (about 10 seconds) and the leak test keeps its rounds.
|
|
8
|
+
- **The glide test ends on the page's clock** (MODULES-1062). "Switching bodies glides" waited real seconds for the clock to carry the glide and the let-go of the pictures; it owns the clock and runs the page's time through, as the other ride tests do.
|
|
9
|
+
- **freezeClock's widening is held by a test** (MODULES-1064). When a loaded machine has run the page's clock past the 3 second margin, `freezeClock` reads the time again and asks with 4 and then 16 times the margin; a test with a fake page now holds that, and that any other answer is given back at once.
|
|
10
|
+
- **The satellites buffer test reads the buffers after the draw** (MODULES-1065, 1086). "Taking a group away frees its buffers" counted the GL buffers after a fixed 800 ms; it now reads the draw count in the same turn as the change, waits for the draw that follows and for the view to be still, and then counts.
|
|
11
|
+
- **The glide into the above view is counted on the page** (MODULES-1190). `ride-above.gl.ts` counts each glide at every animation frame (an earlier fix, e545a3d); checked again with 5 repeats under CPU throttle 4 and with the glide taken out of the product, which fails it.
|
|
12
|
+
|
|
13
|
+
## 0.51.0 - 2026-11-13
|
|
14
|
+
|
|
15
|
+
- **The ridden satellite's own orbit grows out of the camera** (MODULES-1340). In Ride along the orbit ahead, seen edge-on, was a hard bright stroke. Its opacity now rises from nothing at the camera to the path's whole look about 300 km along it (`RIDE_PATH_FADE_KM`, a smooth rise worked out in the ribbon shader from each point's distance to the camera: no extra draw, nothing drawn at rest, and every other path unchanged). The ribbon now reaches the camera for it instead of stopping 64 km short.
|
|
16
|
+
- **The ridden satellite's group orbit line is left out** (MODULES-1340). While a satellite is ridden, the group's own orbit line for it is not drawn, nor the lines of objects on the same orbit (the modules of the ISS), because the ribbon draws its path in the `selected` look; with `selected-path` off the ridden satellite has no orbit line, which is what that switch means. The other satellites keep their lines, and all of them come back when the ride ends. `stats.satellites.orbitLines` counts the group orbit lines drawn.
|
|
17
|
+
- **A test that a painter's model brings no light of its own** (MODULES-1293). The ISS model test now counts the lights each live GL program was made for and wants every lit one made for the scene's one Sun; with the strip switched off it fails. Test only.
|
|
18
|
+
|
|
3
19
|
## 0.50.0 - 2026-11-13
|
|
4
20
|
|
|
5
21
|
- **The catalogue search folds kana** (MODULES-1268). `findInCatalogue` folds hiragana to katakana and small kana to full-size on both sides of the comparison (and half-width katakana by NFKC), so `はっぶる` finds `ハッブル`, in satellite names and group labels; the long-vowel mark is left alone. `foldKana(text)` is the same fold, exported from `@johnmorrisdotca/chikyu-earth/satellites` for a page's own search box.
|
package/README.md
CHANGED
|
@@ -612,7 +612,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
612
612
|
|
|
613
613
|
## How to cite
|
|
614
614
|
|
|
615
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
615
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.51.1) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
616
616
|
|
|
617
617
|
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.
|
|
618
618
|
|
|
@@ -1625,7 +1625,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1625
1625
|
let epochMs = 0;
|
|
1626
1626
|
for (const group of this.#model.satellites.groups.values())
|
|
1627
1627
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1628
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, estimated: drawn.estimated };
|
|
1628
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, orbitLines: drawn.orbitLines, estimated: drawn.estimated };
|
|
1629
1629
|
}
|
|
1630
1630
|
// A press that does not turn the view (under 6 pixels) on a satellite tells the page, which chooses it with `selectSatellite` if it likes.
|
|
1631
1631
|
#downX = 0;
|
|
@@ -2359,7 +2359,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2359
2359
|
let epochMs = 0;
|
|
2360
2360
|
for (const group of this.#model.satellites.groups.values())
|
|
2361
2361
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
2362
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, estimated: drawn.estimated };
|
|
2362
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, orbitLines: drawn.orbitLines, estimated: drawn.estimated };
|
|
2363
2363
|
}
|
|
2364
2364
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
2365
2365
|
#readSpeed() {
|
package/dist/space/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FA
|
|
|
7
7
|
export { genericSatellite, satelliteKind, type SatelliteKind } from "./generic-satellite.ts";
|
|
8
8
|
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam, type BeamCells, type BeamOptions } from "../beam/geometry.ts";
|
|
9
9
|
export type { BeamStats } from "../beam/layer.ts";
|
|
10
|
+
export { RIDE_PATH_FADE_KM } from "./path-ribbons.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { earthHides } from "./satellite-layer.js";
|
|
|
8
8
|
export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FADE_FROM_KM, MODEL_FADE_TO_KM, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
9
9
|
export { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
10
10
|
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam } from "../beam/geometry.js";
|
|
11
|
+
export { RIDE_PATH_FADE_KM } from "./path-ribbons.js";
|
|
@@ -6,10 +6,23 @@ type Three = ThreeParts;
|
|
|
6
6
|
export declare const PATH_POINTS = 120;
|
|
7
7
|
/** The paths the mesh can hold: those of the page and the chosen satellite's own. */
|
|
8
8
|
export declare const PATH_SLOTS: number;
|
|
9
|
+
/**
|
|
10
|
+
* The distance, in kilometres, over which the orbit of a satellite being ridden grows out of the camera: nothing at the camera, all of its look by this far along the path (a smooth step in between).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { RIDE_PATH_FADE_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
15
|
+
*
|
|
16
|
+
* console.log(RIDE_PATH_FADE_KM); // 300
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const RIDE_PATH_FADE_KM = 300;
|
|
9
20
|
/** What one slot is told: the loop's points (3 numbers each, {@link PATH_POINTS} of them) and its look. */
|
|
10
21
|
export interface RibbonPath {
|
|
11
22
|
positions: Float32Array;
|
|
12
23
|
style: PathStyle;
|
|
24
|
+
/** Earth radii from the camera over which the path fades in (nothing at the camera, all of its opacity at this distance); 0 or missing draws it at its look everywhere. */
|
|
25
|
+
fade?: number;
|
|
13
26
|
}
|
|
14
27
|
export interface PathRibbons {
|
|
15
28
|
/** Write the paths into the buffers, none for an empty list. Costs nothing on the GPU until the next draw, and nothing is drawn while there are no paths. */
|
|
@@ -11,6 +11,9 @@ attribute vec2 corner;
|
|
|
11
11
|
attribute vec4 ink;
|
|
12
12
|
attribute vec4 look;
|
|
13
13
|
attribute float span;
|
|
14
|
+
attribute float grow;
|
|
15
|
+
varying vec3 vWorld;
|
|
16
|
+
varying float vGrow;
|
|
14
17
|
varying vec4 vInk;
|
|
15
18
|
varying float vEdge;
|
|
16
19
|
varying float vHalf;
|
|
@@ -20,13 +23,23 @@ void main() {
|
|
|
20
23
|
mat4 m = projectionMatrix * modelViewMatrix;
|
|
21
24
|
vec4 a = m * vec4(position, 1.0);
|
|
22
25
|
vec4 b = m * vec4(other, 1.0);
|
|
23
|
-
|
|
26
|
+
vec3 wa = position;
|
|
27
|
+
vec3 wb = other;
|
|
28
|
+
// a path that grows out of the camera is drawn right up to it (the camera of a ride is a few kilometres from the craft); the others stop 64 km short of it, as they always have
|
|
29
|
+
float near = grow > 0.0 ? 0.00002 : 0.01;
|
|
24
30
|
if (a.w < near && b.w < near) {
|
|
25
31
|
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
|
-
if (a.w < near)
|
|
29
|
-
|
|
34
|
+
if (a.w < near) {
|
|
35
|
+
float t = (near - a.w) / (b.w - a.w);
|
|
36
|
+
a = mix(a, b, t);
|
|
37
|
+
wa = mix(wa, wb, t);
|
|
38
|
+
} else if (b.w < near) {
|
|
39
|
+
float t = (near - b.w) / (a.w - b.w);
|
|
40
|
+
b = mix(b, a, t);
|
|
41
|
+
wb = mix(wb, wa, t);
|
|
42
|
+
}
|
|
30
43
|
vec2 hres = res * 0.5;
|
|
31
44
|
vec2 sa = a.xy / a.w * hres;
|
|
32
45
|
vec2 sb = b.xy / b.w * hres;
|
|
@@ -41,12 +54,16 @@ void main() {
|
|
|
41
54
|
vec2 at = s + normal * corner.y * reach;
|
|
42
55
|
gl_Position = vec4(at / hres * p.w, p.z, p.w);
|
|
43
56
|
vInk = ink;
|
|
57
|
+
vWorld = atB ? wb : wa;
|
|
58
|
+
vGrow = grow;
|
|
44
59
|
vEdge = corner.y * reach;
|
|
45
60
|
vHalf = look.x * 0.5;
|
|
46
61
|
vAlong = (look.w + (atB ? span : 0.0)) * dashScale;
|
|
47
62
|
vDash = look.yz;
|
|
48
63
|
}`;
|
|
49
64
|
const FRAG = /* glsl */ `
|
|
65
|
+
varying vec3 vWorld;
|
|
66
|
+
varying float vGrow;
|
|
50
67
|
varying vec4 vInk;
|
|
51
68
|
varying float vEdge;
|
|
52
69
|
varying float vHalf;
|
|
@@ -60,10 +77,24 @@ void main() {
|
|
|
60
77
|
float inside = m < vDash.x ? min(m, vDash.x - m) : -min(m - vDash.x, period - m);
|
|
61
78
|
cover *= clamp(inside + 0.5, 0.0, 1.0);
|
|
62
79
|
}
|
|
80
|
+
// a path being ridden grows out of the camera: the distance is the point's own on the chord (the loop is 120 points, some 350 km apart, so a fade taken at the ends alone would not reach nothing at the craft)
|
|
81
|
+
float grown = vGrow > 0.0 ? smoothstep(0.0, vGrow, distance(vWorld, cameraPosition)) : 1.0;
|
|
82
|
+
cover *= grown;
|
|
63
83
|
if (cover <= 0.0) discard;
|
|
64
84
|
gl_FragColor = vec4(vInk.rgb, vInk.a * cover);
|
|
65
85
|
#include <colorspace_fragment>
|
|
66
86
|
}`;
|
|
87
|
+
/**
|
|
88
|
+
* The distance, in kilometres, over which the orbit of a satellite being ridden grows out of the camera: nothing at the camera, all of its look by this far along the path (a smooth step in between).
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { RIDE_PATH_FADE_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
93
|
+
*
|
|
94
|
+
* console.log(RIDE_PATH_FADE_KM); // 300
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export const RIDE_PATH_FADE_KM = 300;
|
|
67
98
|
export function createPathRibbons(three, scene) {
|
|
68
99
|
// The quads face either way (a segment's left and right turn with its direction on the screen), so neither side is culled.
|
|
69
100
|
const verts = PATH_SLOTS * PATH_POINTS * 4;
|
|
@@ -73,6 +104,7 @@ export function createPathRibbons(three, scene) {
|
|
|
73
104
|
const ink = new Float32Array(verts * 4);
|
|
74
105
|
const look = new Float32Array(verts * 4);
|
|
75
106
|
const span = new Float32Array(verts);
|
|
107
|
+
const grow = new Float32Array(verts);
|
|
76
108
|
const index = new Uint16Array(PATH_SLOTS * PATH_POINTS * 6);
|
|
77
109
|
for (let q = 0; q < PATH_SLOTS * PATH_POINTS; q += 1) {
|
|
78
110
|
const v = q * 4;
|
|
@@ -87,6 +119,7 @@ export function createPathRibbons(three, scene) {
|
|
|
87
119
|
ink: new three.BufferAttribute(ink, 4),
|
|
88
120
|
look: new three.BufferAttribute(look, 4),
|
|
89
121
|
span: new three.BufferAttribute(span, 1),
|
|
122
|
+
grow: new three.BufferAttribute(grow, 1),
|
|
90
123
|
};
|
|
91
124
|
for (const [name, attribute] of Object.entries(attributes))
|
|
92
125
|
geometry.setAttribute(name, attribute);
|
|
@@ -106,7 +139,7 @@ export function createPathRibbons(three, scene) {
|
|
|
106
139
|
set(paths) {
|
|
107
140
|
count = Math.min(PATH_SLOTS, paths.length);
|
|
108
141
|
for (let p = 0; p < count; p += 1) {
|
|
109
|
-
const { positions, style } = paths[p];
|
|
142
|
+
const { positions, style, fade = 0 } = paths[p];
|
|
110
143
|
colour.set(style.color);
|
|
111
144
|
// the arc length at each point, in Earth radii, for the dashes
|
|
112
145
|
let along = 0;
|
|
@@ -137,6 +170,7 @@ export function createPathRibbons(three, scene) {
|
|
|
137
170
|
look[v * 4 + 2] = style.dash ? style.dash[1] : 0;
|
|
138
171
|
look[v * 4 + 3] = along;
|
|
139
172
|
span[v] = length;
|
|
173
|
+
grow[v] = fade;
|
|
140
174
|
}
|
|
141
175
|
along += length;
|
|
142
176
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
|
|
2
2
|
import { satelliteEmphasis } from "./satellite-focus.js";
|
|
3
3
|
import { BUILT_IN_PATH_STYLES, capPaths, nearestLoop, resolvePathId, styleOf, styleTable } from "./paths.js";
|
|
4
|
-
import { createPathRibbons } from "./path-ribbons.js";
|
|
4
|
+
import { createPathRibbons, RIDE_PATH_FADE_KM } from "./path-ribbons.js";
|
|
5
5
|
/**
|
|
6
6
|
* The longest a streak may be along its orbit, in Earth radii: 0.025, about 160 km, which is what a low satellite covers in a frame at 10 minutes a second (150 km). On the screen that is a share of the Earth's drawn radius, so a streak
|
|
7
7
|
* is a few millimetres when the Earth fills the view, half as long when the Earth is half as large, and a dot when the Earth is tiny. A cap of so many pixels alone would leave the same length on a small Earth, where it looks long.
|
|
@@ -56,10 +56,12 @@ export function longestStreak(segments, count, earthPx) {
|
|
|
56
56
|
}
|
|
57
57
|
return longest * earthPx;
|
|
58
58
|
}
|
|
59
|
-
export const newSatelliteState = () => ({ groups: new Map(), selected: null, marked: new Set(), pinned: [], orbitTint: false, focus: null, modelOver: null, hover: { ref: null, fade: 0, enabled: true, color: "#ffffff", opacity: HOVER_PATH_OPACITY }, paths: { requests: [], overrides: {}, selectedOn: true, version: 0, info: [], dropped: 0, unresolved: 0 }, ridden: null, streakMax: DEFAULT_STREAK_MAX, drawn: { placed: 0, segments: 0, tooFast: false, dotScale: 1, longestStreakPx: 0, streakCapPx: 0, weight: 1, fade: 1, earthPx: 0, updateMs: 0, maxUpdateMs: 0, updates: 0, totalMs: 0, selectedRing: false, hoverPath: false, hoverOpacity: 0, selectedOpacity: 0, pathsDrawn: 0, pathDraws: 0, estimated: 0 } });
|
|
59
|
+
export const newSatelliteState = () => ({ groups: new Map(), selected: null, marked: new Set(), pinned: [], orbitTint: false, focus: null, modelOver: null, hover: { ref: null, fade: 0, enabled: true, color: "#ffffff", opacity: HOVER_PATH_OPACITY }, paths: { requests: [], overrides: {}, selectedOn: true, version: 0, info: [], dropped: 0, unresolved: 0 }, ridden: null, streakMax: DEFAULT_STREAK_MAX, drawn: { placed: 0, segments: 0, tooFast: false, dotScale: 1, longestStreakPx: 0, streakCapPx: 0, weight: 1, fade: 1, earthPx: 0, updateMs: 0, maxUpdateMs: 0, updates: 0, totalMs: 0, selectedRing: false, hoverPath: false, hoverOpacity: 0, selectedOpacity: 0, orbitLines: 0, pathsDrawn: 0, pathDraws: 0, estimated: 0 } });
|
|
60
60
|
/** The most orbits a group may draw all at once, one line each. */
|
|
61
61
|
export const MAX_ORBIT_GROUP = 40;
|
|
62
62
|
const ORBIT_POINTS = 120;
|
|
63
|
+
/** The Earth's radius in kilometres: the unit of a position is one radius. */
|
|
64
|
+
const EARTH_KM = 6371;
|
|
63
65
|
/** How bright the chosen satellite's orbit is. The orbit under the pointer is about a third of this, so the two are told apart at a glance. */
|
|
64
66
|
export const SELECTED_PATH_OPACITY = BUILT_IN_PATH_STYLES["selected"].opacity;
|
|
65
67
|
/** The orbit under the pointer, before it fades. A page may set another with `--chikyu-hover-path-opacity`. */
|
|
@@ -278,7 +280,7 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
278
280
|
line.loop.material.dispose();
|
|
279
281
|
}
|
|
280
282
|
};
|
|
281
|
-
const
|
|
283
|
+
const placeOrbits = (entry, group, time, wall) => {
|
|
282
284
|
const wanted = group.orbits && group.satellites.count <= MAX_ORBIT_GROUP;
|
|
283
285
|
if (!wanted) {
|
|
284
286
|
for (const line of entry.lines)
|
|
@@ -312,6 +314,48 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
312
314
|
entry.linesAt = time;
|
|
313
315
|
entry.linesWall = wall;
|
|
314
316
|
};
|
|
317
|
+
/** The orbit of a line as a plane and a size: the unit normal of the plane (from two points a quarter of a loop apart) and the mean distance from the centre. */
|
|
318
|
+
const planeOf = (positions) => {
|
|
319
|
+
const q = (ORBIT_POINTS / 4) * 3;
|
|
320
|
+
const [ax, ay, az, bx, by, bz] = [positions[0], positions[1], positions[2], positions[q], positions[q + 1], positions[q + 2]];
|
|
321
|
+
const [nx, ny, nz] = [ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx];
|
|
322
|
+
const n = Math.hypot(nx, ny, nz) || 1;
|
|
323
|
+
return { nx: nx / n, ny: ny / n, nz: nz / n, r: (Math.hypot(ax, ay, az) + Math.hypot(bx, by, bz)) / 2 };
|
|
324
|
+
};
|
|
325
|
+
/** Two lines are one orbit when their planes are within half a degree and their sizes within 20 km: the modules of a station, each its own object, are one line drawn several times. */
|
|
326
|
+
const COPLANAR = Math.cos((0.5 * Math.PI) / 180);
|
|
327
|
+
const SAME_SIZE = 20 / EARTH_KM;
|
|
328
|
+
/**
|
|
329
|
+
* The group's own orbit lines, but not the ridden satellite's, nor any line that lies on it (the modules of a station are objects of their own with one orbit): its path is drawn by the ribbons in the `selected` look, with the fade
|
|
330
|
+
* out of the camera (and by nothing at all when the page has that off), and the line would lie over it as a hard stroke. The other satellites keep theirs, and the lines come back when the ride ends.
|
|
331
|
+
*/
|
|
332
|
+
const orbitsOf = (entry, group, name, time, wall) => {
|
|
333
|
+
const ridden = state.ridden !== null && state.ridden.group === name ? state.ridden.index : -1;
|
|
334
|
+
const wanted = group.orbits && group.satellites.count <= MAX_ORBIT_GROUP;
|
|
335
|
+
placeOrbits(entry, group, time, wall);
|
|
336
|
+
const mine = ridden >= 0 ? entry.lines[ridden] : undefined;
|
|
337
|
+
const left = [];
|
|
338
|
+
if (mine) {
|
|
339
|
+
const own = planeOf(mine.positions);
|
|
340
|
+
entry.lines.forEach((line, i) => {
|
|
341
|
+
if (i === ridden)
|
|
342
|
+
left.push(i);
|
|
343
|
+
else if (own.r > 0) {
|
|
344
|
+
const other = planeOf(line.positions);
|
|
345
|
+
if (other.r > 0 && Math.abs(other.nx * own.nx + other.ny * own.ny + other.nz * own.nz) > COPLANAR && Math.abs(other.r - own.r) < SAME_SIZE)
|
|
346
|
+
left.push(i);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
for (const i of entry.hid) {
|
|
351
|
+
const back = entry.lines[i];
|
|
352
|
+
if (back && !left.includes(i))
|
|
353
|
+
back.loop.visible = wanted && (group.satellites.visible(i) || back.positions.some((v) => v !== 0));
|
|
354
|
+
}
|
|
355
|
+
for (const i of left)
|
|
356
|
+
entry.lines[i].loop.visible = false;
|
|
357
|
+
entry.hid = left;
|
|
358
|
+
};
|
|
315
359
|
const find = (ref) => state.groups.get(ref.group)?.satellites;
|
|
316
360
|
const refKey = (ref) => `${ref.group}:${ref.index}`;
|
|
317
361
|
const cleanRef = (ref) => {
|
|
@@ -350,9 +394,10 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
350
394
|
if (!ref)
|
|
351
395
|
continue;
|
|
352
396
|
const look = styleOf(one.request, table);
|
|
353
|
-
wanted.push({ id: one.request.id, ref, name: look.name, style: look.style });
|
|
397
|
+
wanted.push({ id: one.request.id, ref, name: look.name, style: look.style, fade: 0 });
|
|
354
398
|
}
|
|
355
399
|
if (pathState.selectedOn) {
|
|
400
|
+
const ridingRef = cleanRef(state.ridden);
|
|
356
401
|
const own = [chosen, state.ridden].map(cleanRef);
|
|
357
402
|
const seen = new Set();
|
|
358
403
|
for (const ref of own) {
|
|
@@ -360,10 +405,12 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
360
405
|
continue;
|
|
361
406
|
seen.add(refKey(ref));
|
|
362
407
|
const norad = find(ref)?.sets[ref.index]?.NORAD_CAT_ID;
|
|
363
|
-
|
|
408
|
+
// the orbit of the satellite being ridden, seen from it, is a line from the craft to the edge of the picture: it grows out of the camera instead
|
|
409
|
+
const riding = ridingRef !== null && refKey(ridingRef) === refKey(ref);
|
|
410
|
+
wanted.push({ id: norad ?? refKey(ref), ref, name: "selected", style: table["selected"], fade: riding ? RIDE_PATH_FADE_KM / EARTH_KM : 0 });
|
|
364
411
|
}
|
|
365
412
|
}
|
|
366
|
-
const signature = wanted.map((w) => `${refKey(w.ref)}|${w.name}|${w.style.color}|${w.style.width}|${w.style.opacity}|${w.style.dash ? w.style.dash.join(",") : "-"}`).join(";");
|
|
413
|
+
const signature = wanted.map((w) => `${refKey(w.ref)}|${w.name}|${w.style.color}|${w.style.width}|${w.style.opacity}|${w.style.dash ? w.style.dash.join(",") : "-"}|${w.fade}`).join(";");
|
|
367
414
|
let dirty = signature !== slotsSignature;
|
|
368
415
|
const old = new Map(slots.map((slot) => [slot.key, slot]));
|
|
369
416
|
let empty = 0;
|
|
@@ -373,12 +420,13 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
373
420
|
let slot = old.get(key);
|
|
374
421
|
const set = find(w.ref);
|
|
375
422
|
if (!slot) {
|
|
376
|
-
slot = { key, info: { id: w.id, ref: w.ref, style: w.name }, style: w.style, positions: new Float32Array(ORBIT_POINTS * 3), screen: new Float32Array(ORBIT_POINTS * 2), seen: new Uint8Array(ORBIT_POINTS), at: Number.NaN, wall: 0, empty: false };
|
|
423
|
+
slot = { key, info: { id: w.id, ref: w.ref, style: w.name }, style: w.style, fade: w.fade, positions: new Float32Array(ORBIT_POINTS * 3), screen: new Float32Array(ORBIT_POINTS * 2), seen: new Uint8Array(ORBIT_POINTS), at: Number.NaN, wall: 0, empty: false };
|
|
377
424
|
dirty = true;
|
|
378
425
|
}
|
|
379
426
|
old.delete(key);
|
|
380
427
|
slot.info = { id: w.id, ref: w.ref, style: w.name };
|
|
381
428
|
slot.style = w.style;
|
|
429
|
+
slot.fade = w.fade;
|
|
382
430
|
if (Number.isNaN(slot.at) || (Math.abs(time - slot.at) > ORBIT_REFRESH_GAME_MS && wall - slot.wall > ORBIT_REFRESH_WALL_MS)) {
|
|
383
431
|
slot.at = time;
|
|
384
432
|
slot.wall = wall;
|
|
@@ -393,7 +441,7 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
393
441
|
slots = next;
|
|
394
442
|
if (dirty) {
|
|
395
443
|
slotsSignature = signature;
|
|
396
|
-
ribbons.set(slots.filter((slot) => !slot.empty).map((slot) => ({ positions: slot.positions, style: slot.style })));
|
|
444
|
+
ribbons.set(slots.filter((slot) => !slot.empty).map((slot) => ({ positions: slot.positions, style: slot.style, fade: slot.fade })));
|
|
397
445
|
}
|
|
398
446
|
const own = wanted.filter((w) => w.name === "selected" && pathState.selectedOn);
|
|
399
447
|
pathState.info = slots.filter((slot) => !slot.empty).map((slot) => ({ ...slot.info }));
|
|
@@ -470,7 +518,7 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
470
518
|
streak.visible = false;
|
|
471
519
|
scene.add(streak);
|
|
472
520
|
}
|
|
473
|
-
entry = { source: group.satellites, points, geometry, material, positions, attribute, dim, dimVersion: -1, lines: [], linesAt: Number.NaN, linesWall: 0, style: "", streak, streakPositions, streakColours, streakAttribute, pinWall: 0, pinTime: 0, pinNext: 0 };
|
|
521
|
+
entry = { source: group.satellites, points, geometry, material, positions, attribute, dim, dimVersion: -1, lines: [], hid: [], linesAt: Number.NaN, linesWall: 0, style: "", streak, streakPositions, streakColours, streakAttribute, pinWall: 0, pinTime: 0, pinNext: 0 };
|
|
474
522
|
drawn.set(name, entry);
|
|
475
523
|
}
|
|
476
524
|
const style = `${group.color}|${group.size}|${ratio()}|${dotScale}|${state.orbitTint ? 1 : 0}`;
|
|
@@ -563,12 +611,18 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
563
611
|
}
|
|
564
612
|
placed += group.satellites.placed;
|
|
565
613
|
group.placed = group.satellites.placed;
|
|
566
|
-
orbitsOf(entry, group, time, started);
|
|
614
|
+
orbitsOf(entry, group, name, time, started);
|
|
567
615
|
const opacity = dimmed ? 0.15 : 0.45;
|
|
568
616
|
for (const line of entry.lines)
|
|
569
617
|
line.loop.material.opacity = opacity;
|
|
570
618
|
}
|
|
571
619
|
}
|
|
620
|
+
let lines = 0;
|
|
621
|
+
for (const entry of drawn.values())
|
|
622
|
+
for (const line of entry.lines)
|
|
623
|
+
if (line.loop.visible)
|
|
624
|
+
lines += 1;
|
|
625
|
+
state.drawn.orbitLines = lines;
|
|
572
626
|
if (size)
|
|
573
627
|
ribbons.frame(size.width, size.height, radius);
|
|
574
628
|
const chosen = state.selected;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.1",
|
|
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",
|