astraeus 0.3.0 → 0.5.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +92 -11
  3. package/data/ephemerides/planets/planets.json +1 -1
  4. package/package.json +1 -1
  5. package/src/api/AstraeusScene.d.ts +9 -1
  6. package/src/api/AstraeusScene.js +26 -4
  7. package/src/api/AstraeusScene.node.js +26 -4
  8. package/src/api/activity.d.ts +1 -1
  9. package/src/api/activity.js +1 -1
  10. package/src/api/bodies.d.ts +2 -0
  11. package/src/api/bodies.js +2 -0
  12. package/src/api/data.js +11 -1
  13. package/src/api/errors.d.ts +1 -1
  14. package/src/api/index.d.ts +3 -2
  15. package/src/api/index.js +1 -1
  16. package/src/api/index.node.js +1 -1
  17. package/src/api/mount.d.ts +16 -0
  18. package/src/api/mount.js +13 -1
  19. package/src/api/mount.node.js +13 -1
  20. package/src/api/pathProvenance.d.ts +10 -0
  21. package/src/api/pathProvenance.js +34 -0
  22. package/src/api/scene.d.ts +26 -5
  23. package/src/api/scene.js +197 -44
  24. package/src/api/story.d.ts +41 -1
  25. package/src/api/story.js +63 -1
  26. package/src/api/sunOrbit.d.ts +3 -3
  27. package/src/api/sunOrbit.js +92 -24
  28. package/src/api/viewerLink.d.ts +40 -0
  29. package/src/api/viewerLink.js +86 -0
  30. package/src/app/App.d.ts +4 -1
  31. package/src/app/App.js +42 -6
  32. package/src/app/App.node.js +42 -6
  33. package/src/app/AstraeusScene.d.ts +7 -0
  34. package/src/app/BodySetView.js +3 -2
  35. package/src/app/KeplerPoints.d.ts +1 -1
  36. package/src/app/KeplerPoints.js +3 -2
  37. package/src/app/PointsView.js +3 -2
  38. package/src/app/SceneLabels.d.ts +2 -0
  39. package/src/app/SceneLabels.js +5 -1
  40. package/src/app/TrackedBodyView.d.ts +9 -3
  41. package/src/app/TrackedBodyView.js +54 -14
  42. package/src/app/bodyDraw.js +3 -2
  43. package/src/app/dotMaterial.d.ts +11 -0
  44. package/src/app/dotMaterial.js +38 -0
  45. package/src/app/experienceDefinition.d.ts +12 -0
  46. package/src/app/mission.d.ts +3 -1
  47. package/src/app/mission.js +1 -1
  48. package/src/app/openClock.d.ts +1 -1
  49. package/src/app/openClock.js +3 -0
  50. package/src/app/pathRules.d.ts +7 -3
  51. package/src/app/pathRules.js +9 -5
  52. package/src/app/sceneContentsHooks.js +2 -1
  53. package/src/app/sceneDebug.d.ts +4 -2
  54. package/src/app/sceneFrame.d.ts +2 -2
  55. package/src/app/sceneFrame.js +7 -2
  56. package/src/app/sceneFraming.d.ts +1 -1
  57. package/src/app/sceneFraming.js +9 -3
  58. package/src/app/viewerPort.d.ts +33 -0
  59. package/src/app/viewerPort.js +1 -0
  60. package/src/core/bodies/io.js +1 -1
  61. package/src/core/bodies/jupiterMoons.d.ts +1 -1
  62. package/src/core/bodies/jupiterMoons.js +6 -6
  63. package/src/core/bodies/moonSystem.d.ts +15 -1
  64. package/src/core/bodies/moonSystem.js +58 -7
  65. package/src/core/bodies/outerPlanets.js +1 -1
  66. package/src/core/bodies/planetMoons.js +10 -10
  67. package/src/core/chebyshevEphemeris.d.ts +7 -1
  68. package/src/core/chebyshevEphemeris.js +24 -7
  69. package/src/core/clock.d.ts +8 -0
  70. package/src/core/clock.js +14 -0
  71. package/src/core/pacing.d.ts +24 -0
  72. package/src/core/pacing.js +35 -0
  73. package/src/core/planetModels.d.ts +4 -1
  74. package/src/core/planetModels.js +6 -1
  75. package/src/core/planetSeries.d.ts +3 -0
  76. package/src/core/planetSeries.js +8 -1
  77. package/src/core/scalePolicy.d.ts +2 -0
  78. package/src/core/scalePolicy.js +2 -0
  79. package/src/core/timeWindow.d.ts +2 -0
  80. package/src/core/timeWindow.js +4 -3
  81. package/src/shell/AstraeusShell.d.ts +6 -2
  82. package/src/shell/AstraeusShell.js +3 -3
  83. package/src/shell/AstraeusShell.node.js +3 -3
  84. package/src/shell/TimelineBar.d.ts +4 -2
  85. package/src/shell/TimelineBar.js +15 -6
  86. package/src/shell/TimelineBar.node.js +15 -6
  87. package/src/shell/experience.d.ts +3 -1
  88. package/src/shell/infoModel.js +5 -4
  89. package/src/shell/timelineModel.d.ts +2 -3
  90. package/src/shell/timelineModel.js +3 -11
  91. package/src/synthetic/syntheticJourneyScene.d.ts +9 -0
  92. package/src/synthetic/syntheticJourneyScene.js +75 -0
  93. package/src/synthetic/syntheticProbeDefinition.d.ts +5 -0
  94. package/src/synthetic/syntheticProbeDefinition.js +38 -0
@@ -13,8 +13,8 @@ export declare function circlesTheSun(catalogue: BodyCatalogue, id: BodyId): boo
13
13
  */
14
14
  export declare function sunOrbitLayer(catalogue: BodyCatalogue, id: BodyId, startUtcMs: number, color: string, given?: EccentricSampling): PathLayer | undefined;
15
15
  /**
16
- * The farthest a body that circles the Sun gets from it, in km: a(1+e) when the period and eccentricity are known (published elements or the
17
- * catalogue's comet sampling; a from Kepler's third law about the Sun), else the largest Sun distance over one full turn of its own state source.
18
- * A planet's source reads the planet series, so those must be loaded. Throws `no-orbit` for a body that completes no turn in the search.
16
+ * The farthest a body that circles the Sun gets from it, in km, by the same rule as its orbit line: a(1+e) when the period and eccentricity are known
17
+ * (published elements, the catalogue's comet sampling) or when the line is the osculating ellipse; else the largest Sun distance over one full turn of
18
+ * its own state source. A planet's source reads the planet series, so those must be loaded. Throws `no-orbit` for a body drawn by neither form.
19
19
  */
20
20
  export declare function farthestSunDistanceKm(catalogue: BodyCatalogue, id: BodyId, startUtcMs: number, given?: EccentricSampling): number;
@@ -1,12 +1,15 @@
1
1
  import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
2
2
  import { BUILT_IN_SAMPLING, EARTH_EPHEMERIS } from "../core/bodies/index.js";
3
+ import { fillKeplerRangeKm, keplerElementsFromStates } from "../core/keplerElements.js";
4
+ import { createState, EQJ } from "../core/state.js";
5
+ import { TimeScaleOutOfRangeError } from "../core/timeScale.js";
3
6
  import { createEarthSunTrajectory, fullTurnSpanMs } from "../core/sunCentredSources.js";
4
7
  import { rootBodyId } from "../assets/catalogue.js";
5
8
  import { SceneError } from "./errors.js";
6
9
  const DAY_MS = 86_400_000;
7
- /** The turn search walks in two-day steps; the longest orbit among the planets is a dozen years. */
10
+ /** The turn search walks in two-day steps; a full turn is looked for up to about thirty years (Saturn's). */
8
11
  const TURN_STEP_MS = 2 * DAY_MS;
9
- const TURN_MAX_STEPS = 3_000;
12
+ const TURN_MAX_STEPS = 6_000;
10
13
  const TURN_SAMPLES = 361;
11
14
  /** The id of a body's Sun-orbit line. */
12
15
  export const sunOrbitIdOf = (id) => `${id}-orbit`;
@@ -18,19 +21,86 @@ function trajectoryOf(catalogue, id) {
18
21
  const adapter = createOrbAstronomyAdapter();
19
22
  return id === "earth" ? createEarthSunTrajectory(adapter) : catalogue.get(id).source.create(adapter);
20
23
  }
24
+ const VELOCITY_STEP_MS = DAY_MS / 2;
25
+ /** The body's velocity from its position source (which models none): a central difference, or a one-sided one at the end of the source's years. */
26
+ function velocityKmS(source, timeUtcMs, center) {
27
+ const at = (t) => {
28
+ try {
29
+ return source.stateAt(t, center).positionKm;
30
+ }
31
+ catch (error) {
32
+ if (error instanceof RangeError)
33
+ return undefined;
34
+ throw error;
35
+ }
36
+ };
37
+ const [before, after] = [at(timeUtcMs - VELOCITY_STEP_MS), at(timeUtcMs + VELOCITY_STEP_MS)];
38
+ const here = source.stateAt(timeUtcMs, center).positionKm;
39
+ const [from, to, seconds] = before !== undefined && after !== undefined ? [before, after, VELOCITY_STEP_MS / 500] : after !== undefined ? [here, after, VELOCITY_STEP_MS / 1000] : before !== undefined ? [before, here, VELOCITY_STEP_MS / 1000] : [here, here, 1];
40
+ return [0, 1, 2].map((axis) => (to[axis] - from[axis]) / seconds);
41
+ }
42
+ /** The two-body ellipse osculating at `startUtcMs`, as a source, the span of one turn from periapsis and its sampling; undefined when the body is not bound or no Sun GM is known. */
43
+ function osculatingOrbit(catalogue, id, source, startUtcMs) {
44
+ const root = rootBodyId(catalogue);
45
+ const mu = catalogue.get(root).definition.gmKm3S2;
46
+ if (mu === undefined)
47
+ return undefined;
48
+ const position = source.stateAt(startUtcMs, root).positionKm;
49
+ const velocity = velocityKmS(source, startUtcMs, root);
50
+ if (![...position, ...velocity].every(Number.isFinite))
51
+ return undefined;
52
+ const elements = keplerElementsFromStates(Float64Array.from([position[0], position[1], position[2], ...velocity]), 1, mu, startUtcMs);
53
+ const a = elements.semiMajorAxisKm[0];
54
+ const e = elements.eccentricity[0];
55
+ if (!(a > 0) || !(e >= 0 && e < 1) || !Number.isFinite(elements.meanMotionRadS[0]))
56
+ return undefined;
57
+ const periodMs = Math.round((2 * Math.PI * 1000) / elements.meanMotionRadS[0]);
58
+ const periapsisUtcMs = Math.round(startUtcMs - (elements.meanAnomalyRad[0] * 1000) / elements.meanMotionRadS[0]);
59
+ return { source: ellipseSource(id, elements), span: { startUtcMs: periapsisUtcMs, endUtcMs: periapsisUtcMs + periodMs }, sampling: { eccentricity: e, periodMs, periapsisUtcMs }, osculating: true, farthestKm: a * (1 + e) };
60
+ }
61
+ function ellipseSource(id, elements) {
62
+ return Object.freeze({
63
+ body: id,
64
+ stateAt(timeUtcMs) {
65
+ const out = new Float64Array(3);
66
+ fillKeplerRangeKm(elements, timeUtcMs, out, 0, 1);
67
+ return createState({ body: id, center: "sun", timeUtcMs, frame: EQJ, positionKm: out, orientation: null }, () => false);
68
+ },
69
+ });
70
+ }
71
+ /**
72
+ * How a body that circles the Sun is drawn, one rule for every body and never by name: with published elements (`given`, or the catalogue's comet
73
+ * sampling) from periapsis for one period; else one full turn of its own source when the source covers a whole turn from `startUtcMs`; else (a source
74
+ * that ends first, such as the planet series for Uranus and Neptune) the two-body ellipse osculating at `startUtcMs`. Undefined when none can be drawn.
75
+ */
76
+ function drawnOrbit(catalogue, id, startUtcMs, given) {
77
+ const source = trajectoryOf(catalogue, id);
78
+ const sampling = given ?? BUILT_IN_SAMPLING[id];
79
+ if (sampling !== undefined) {
80
+ const gm = catalogue.get(rootBodyId(catalogue)).definition.gmKm3S2;
81
+ const semiMajorKm = Math.cbrt(gm * (sampling.periodMs / 1000 / (2 * Math.PI)) ** 2);
82
+ return { source, span: { startUtcMs: sampling.periapsisUtcMs, endUtcMs: sampling.periapsisUtcMs + Math.round(sampling.periodMs) }, sampling, osculating: false, farthestKm: semiMajorKm * (1 + sampling.eccentricity) };
83
+ }
84
+ const span = turnSpan(source, startUtcMs);
85
+ if (span !== undefined)
86
+ return { source, span, sampling: undefined, osculating: false, farthestKm: undefined };
87
+ return osculatingOrbit(catalogue, id, source, startUtcMs);
88
+ }
21
89
  /**
22
90
  * The orbit line of a body that circles the Sun: one full turn from `startUtcMs`, from the body's own state source. A body given published elements
23
91
  * (`sampling`) is drawn from its periapsis for one period with samples spaced by eccentric anomaly, so a sharp orbit is smooth. Returns undefined when
24
92
  * the body completes no turn within the search (a comet's century-long orbit given without elements).
25
93
  */
26
94
  export function sunOrbitLayer(catalogue, id, startUtcMs, color, given) {
27
- const sampling = given ?? BUILT_IN_SAMPLING[id];
28
- const { definition, visual } = catalogue.get(id);
29
- const source = trajectoryOf(catalogue, id);
30
- const span = sampling === undefined ? turnSpan(source, startUtcMs) : { startUtcMs: sampling.periapsisUtcMs, endUtcMs: sampling.periapsisUtcMs + Math.round(sampling.periodMs) };
31
- if (span === undefined)
95
+ const drawn = drawnOrbit(catalogue, id, startUtcMs, given);
96
+ if (drawn === undefined)
32
97
  return undefined;
98
+ const { definition, visual } = catalogue.get(id);
99
+ const { source, span, sampling, osculating } = drawn;
33
100
  const provenance = id === "earth" ? EARTH_EPHEMERIS.provenance : definition.accuracy.position;
101
+ const limitation = osculating
102
+ ? `${definition.label}'s source does not cover a whole turn from the scene's opening time, so this is the two-body ellipse osculating at that time (position and velocity from the source, the Sun's gravity alone): perturbations over a turn are not drawn, and the line leaves the source's own positions as the years pass from the opening time. Samples are spaced by eccentric anomaly and joined by straight segments.`
103
+ : sampling === undefined ? "A turn's samples joined by straight segments." : "One full turn of unperturbed two-body motion from periapsis; samples are spaced by eccentric anomaly and joined by straight segments.";
34
104
  return {
35
105
  kind: "orbit",
36
106
  color: color || visual.material.color,
@@ -44,9 +114,11 @@ export function sunOrbitLayer(catalogue, id, startUtcMs, color, given) {
44
114
  color: color || visual.material.color,
45
115
  labelPriority: 50,
46
116
  showLabel: false,
47
- description: `${definition.label}'s path round the Sun for one full turn, drawn from the same position source that places ${definition.label}.`,
117
+ description: osculating
118
+ ? `${definition.label}'s path round the Sun for one turn, drawn as the two-body ellipse osculating at the scene's opening time.`
119
+ : `${definition.label}'s path round the Sun for one full turn, drawn from the same position source that places ${definition.label}.`,
48
120
  provenance,
49
- knownLimitations: [sampling === undefined ? "A turn's samples joined by straight segments." : "One full turn of unperturbed two-body motion from periapsis; samples are spaced by eccentric anomaly and joined by straight segments."],
121
+ knownLimitations: [limitation],
50
122
  },
51
123
  };
52
124
  }
@@ -55,30 +127,26 @@ function turnSpan(source, startUtcMs) {
55
127
  return { startUtcMs, endUtcMs: startUtcMs + fullTurnSpanMs(source, startUtcMs, TURN_STEP_MS, TURN_MAX_STEPS) };
56
128
  }
57
129
  catch (error) {
58
- if (error instanceof RangeError && /no full turn/.test(error.message))
130
+ // No full turn in the search, or the source's years end first (the planet series): the source does not cover a whole turn.
131
+ if (error instanceof TimeScaleOutOfRangeError || (error instanceof RangeError && /no full turn|do not cover/.test(error.message)))
59
132
  return undefined;
60
133
  throw error;
61
134
  }
62
135
  }
63
136
  /**
64
- * The farthest a body that circles the Sun gets from it, in km: a(1+e) when the period and eccentricity are known (published elements or the
65
- * catalogue's comet sampling; a from Kepler's third law about the Sun), else the largest Sun distance over one full turn of its own state source.
66
- * A planet's source reads the planet series, so those must be loaded. Throws `no-orbit` for a body that completes no turn in the search.
137
+ * The farthest a body that circles the Sun gets from it, in km, by the same rule as its orbit line: a(1+e) when the period and eccentricity are known
138
+ * (published elements, the catalogue's comet sampling) or when the line is the osculating ellipse; else the largest Sun distance over one full turn of
139
+ * its own state source. A planet's source reads the planet series, so those must be loaded. Throws `no-orbit` for a body drawn by neither form.
67
140
  */
68
141
  export function farthestSunDistanceKm(catalogue, id, startUtcMs, given) {
69
- const sampling = given ?? BUILT_IN_SAMPLING[id];
70
- if (sampling !== undefined) {
71
- const gm = catalogue.get(rootBodyId(catalogue)).definition.gmKm3S2;
72
- const semiMajorKm = Math.cbrt(gm * (sampling.periodMs / 1000 / (2 * Math.PI)) ** 2);
73
- return semiMajorKm * (1 + sampling.eccentricity);
74
- }
75
- const source = trajectoryOf(catalogue, id);
76
- const span = turnSpan(source, startUtcMs);
77
- if (span === undefined)
78
- throw new SceneError("no-orbit", `camera.fitOrbit("${id}"): "${id}" completes no turn within a dozen years and the catalogue does not know its period; add it with addBodyFromElements`);
142
+ const drawn = drawnOrbit(catalogue, id, startUtcMs, given);
143
+ if (drawn === undefined)
144
+ throw new SceneError("no-orbit", `camera.fitOrbit("${id}"): "${id}" completes no turn within thirty years and its position and the Sun's gravity do not give a bound ellipse; add it with addBodyFromElements`);
145
+ if (drawn.farthestKm !== undefined)
146
+ return drawn.farthestKm;
79
147
  let farthest = 0;
80
148
  for (let k = 0; k < TURN_SAMPLES; k += 1) {
81
- const [x, y, z] = source.stateAt(Math.round(span.startUtcMs + ((span.endUtcMs - span.startUtcMs) * k) / (TURN_SAMPLES - 1)), rootBodyId(catalogue)).positionKm;
149
+ const [x, y, z] = drawn.source.stateAt(Math.round(drawn.span.startUtcMs + ((drawn.span.endUtcMs - drawn.span.startUtcMs) * k) / (TURN_SAMPLES - 1)), rootBodyId(catalogue)).positionKm;
82
150
  farthest = Math.max(farthest, Math.hypot(x, y, z));
83
151
  }
84
152
  return farthest;
@@ -0,0 +1,40 @@
1
+ import type { ViewerChangeCause, ViewerControl, ViewerPort, ViewerState } from "../app/viewerPort.js";
2
+ import { type TimeInput } from "./time.js";
3
+ /** What a host is told when the viewer's time, speed or playing state changes. */
4
+ export interface ViewerChange {
5
+ /** The viewer's time, Unix milliseconds UTC. */
6
+ readonly time: number;
7
+ /** Simulated seconds per real second. */
8
+ readonly rate: number;
9
+ readonly playing: boolean;
10
+ /** `playback`: the clock ran on; `visitor`: someone used the timeline; `host`: the host page called `setTime` or `setRate`. */
11
+ readonly cause: ViewerChangeCause;
12
+ }
13
+ /** Where the playback rate comes from. `scene` is the rate the scene opened at; `chosen` is one a visitor or the host picked, which stays until it is released. */
14
+ export type RateSource = "scene" | "chosen";
15
+ /**
16
+ * Joins a host page to a mounted viewer's one clock: reads, sets and change callbacks. Created by `mount` and `AstraeusScene`; the viewer attaches
17
+ * its clock controls when it opens and detaches when it closes.
18
+ */
19
+ export declare class ViewerLink implements ViewerPort {
20
+ #private;
21
+ attach(control: ViewerControl): void;
22
+ detach(): void;
23
+ /** Stops all callbacks for good (the host unmounted). */
24
+ close(): void;
25
+ get rateSource(): RateSource;
26
+ /** The viewer's time (Unix milliseconds UTC), or undefined before it is drawn or after it is gone. */
27
+ get time(): number | undefined;
28
+ get rate(): number | undefined;
29
+ get playing(): boolean | undefined;
30
+ setTime(time: TimeInput): void;
31
+ /**
32
+ * Only a speed the timeline offers is taken, so the speed picker always shows what is running; any other number throws `bad-timeline`.
33
+ * `"auto"` hands the rate back to the scene's pacing (`setTimeline({ pacing })`) and throws `bad-timeline` when the scene has none. The in-between speeds pacing
34
+ * runs at are never set through here; they arrive in `onChange` and `rate`.
35
+ */
36
+ setRate(rate: number | "auto"): void;
37
+ /** Calls `listener` whenever the time, speed or playing state changes; returns the function that stops it. */
38
+ onChange(listener: (change: ViewerChange) => void): () => void;
39
+ publish(state: ViewerState, cause: ViewerChangeCause): void;
40
+ }
@@ -0,0 +1,86 @@
1
+ import { SceneError } from "./errors.js";
2
+ import { toUtcMs } from "./time.js";
3
+ const NOT_OPEN = "the viewer is not drawn yet (or is gone); wait for `ready` first";
4
+ /**
5
+ * Joins a host page to a mounted viewer's one clock: reads, sets and change callbacks. Created by `mount` and `AstraeusScene`; the viewer attaches
6
+ * its clock controls when it opens and detaches when it closes.
7
+ */
8
+ export class ViewerLink {
9
+ #control;
10
+ #last;
11
+ #rateSource = "scene";
12
+ #listeners = new Set();
13
+ attach(control) {
14
+ this.#control = control;
15
+ this.#last = control.read();
16
+ this.#rateSource = "scene";
17
+ }
18
+ detach() {
19
+ this.#control = undefined;
20
+ this.#last = undefined;
21
+ }
22
+ /** Stops all callbacks for good (the host unmounted). */
23
+ close() {
24
+ this.detach();
25
+ this.#listeners.clear();
26
+ }
27
+ get rateSource() { return this.#rateSource; }
28
+ /** The viewer's time (Unix milliseconds UTC), or undefined before it is drawn or after it is gone. */
29
+ get time() { return this.#control?.read().timeUtcMs; }
30
+ get rate() { return this.#control?.read().rate; }
31
+ get playing() { return this.#control?.read().playing; }
32
+ setTime(time) {
33
+ const control = this.#open("setTime");
34
+ const timeUtcMs = toUtcMs(time, "setTime");
35
+ const { startUtcMs, endUtcMs } = control.window;
36
+ if (timeUtcMs < startUtcMs || timeUtcMs > endUtcMs) {
37
+ throw new SceneError("bad-time", `setTime: ${new Date(timeUtcMs).toISOString()} is outside the timeline (${new Date(startUtcMs).toISOString()} to ${new Date(endUtcMs).toISOString()})`);
38
+ }
39
+ control.seek(timeUtcMs);
40
+ this.publish(control.read(), "host");
41
+ }
42
+ /**
43
+ * Only a speed the timeline offers is taken, so the speed picker always shows what is running; any other number throws `bad-timeline`.
44
+ * `"auto"` hands the rate back to the scene's pacing (`setTimeline({ pacing })`) and throws `bad-timeline` when the scene has none. The in-between speeds pacing
45
+ * runs at are never set through here; they arrive in `onChange` and `rate`.
46
+ */
47
+ setRate(rate) {
48
+ const control = this.#open("setRate");
49
+ if (rate === "auto") {
50
+ if (!control.paced)
51
+ throw new SceneError("bad-timeline", "setRate: \"auto\" needs a scene with pacing; give setTimeline({ pacing })");
52
+ control.setRate("auto");
53
+ this.#rateSource = "scene";
54
+ this.publish(control.read(), "host");
55
+ return;
56
+ }
57
+ if (!control.rates.includes(rate))
58
+ throw new SceneError("bad-timeline", `setRate: ${String(rate)} is not one of the offered speeds (${control.rates.join(", ")}); offer it with setTimeline({ rates })`);
59
+ control.setRate(rate);
60
+ this.#rateSource = "chosen";
61
+ this.publish(control.read(), "host");
62
+ }
63
+ /** Calls `listener` whenever the time, speed or playing state changes; returns the function that stops it. */
64
+ onChange(listener) {
65
+ this.#listeners.add(listener);
66
+ return () => { this.#listeners.delete(listener); };
67
+ }
68
+ publish(state, cause) {
69
+ const last = this.#last;
70
+ if (last !== undefined && last.timeUtcMs === state.timeUtcMs && last.rate === state.rate && last.playing === state.playing && last.auto === state.auto)
71
+ return;
72
+ if (state.auto !== undefined)
73
+ this.#rateSource = state.auto ? "scene" : "chosen";
74
+ else if (cause === "visitor" && last !== undefined && last.rate !== state.rate)
75
+ this.#rateSource = "chosen";
76
+ this.#last = state;
77
+ const change = { time: state.timeUtcMs, rate: state.rate, playing: state.playing, cause };
78
+ for (const listener of [...this.#listeners])
79
+ listener(change);
80
+ }
81
+ #open(what) {
82
+ if (this.#control === undefined)
83
+ throw new SceneError("missing-data", `${what}: ${NOT_OPEN}`);
84
+ return this.#control;
85
+ }
86
+ }
package/src/app/App.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ViewerPort } from "./viewerPort.js";
1
2
  import { type ExperienceDefinition } from "./experienceDefinition.js";
2
3
  /** The labels switched off at the start: objects that set `showLabel: false`, then `?labels=<id>:on|off,...` over them. */
3
4
  export declare function hiddenLabelsFrom(search: string, objects: readonly {
@@ -9,9 +10,11 @@ export declare function loopFromSearch(search: string, fallback: boolean): boole
9
10
  /**
10
11
  * `onOpenAddress`: the entry's way to open a switch's address in place; without it a switch navigates the page.
11
12
  * `writeTitle`: whether the page heading is set to the experience's name (default true); `mount` and `AstraeusScene` pass false so a host page keeps its own title.
13
+ * `host`: the link a host page reads and sets the one clock through (time, speed) and hears its changes from; every change goes through the same handlers as the timeline's own controls.
12
14
  */
13
- export declare function App({ definition, onOpenAddress, writeTitle }: {
15
+ export declare function App({ definition, onOpenAddress, writeTitle, host }: {
14
16
  readonly definition: ExperienceDefinition;
15
17
  readonly onOpenAddress?: (address: string) => void;
16
18
  readonly writeTitle?: boolean;
19
+ readonly host?: ViewerPort;
17
20
  }): import("react").JSX.Element;
package/src/app/App.js CHANGED
@@ -2,6 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
4
4
  import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
5
+ import { applyPacing } from "../core/pacing.js";
5
6
  import { openClock } from "./openClock.js";
6
7
  import { createSolarSystemScale } from "../core/scalePolicy.js";
7
8
  import { bodySetsOf, cameraReachOf, catalogueOf, compositionOf, experienceWithGroups, groupsOf, initialObjectIdOf, mountedBodiesOf, pageTitleOf, scaleChoiceIdsOf, sceneCenterOf, sunCentredOf, trackedBodiesOf, visualOverridesOf } from "./experienceDefinition.js";
@@ -106,6 +107,8 @@ function buildRuntime(definition) {
106
107
  cameraReach: cameraReachOf(definition),
107
108
  sky: skySettingsOf(definition),
108
109
  loopWindow: definition.experience.window,
110
+ ...(definition.experience.hideTimeline === true ? {} : { stopAtWindow: true }),
111
+ ...(definition.pacing === undefined ? {} : { pacing: definition.pacing }),
109
112
  up: viewUpVector(startViewUp(definition)),
110
113
  };
111
114
  }
@@ -123,6 +126,7 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
123
126
  cameraRequest: null,
124
127
  showAnchorLabels: labelStart(definition) === true && runtime.trackedBodies.length > 0,
125
128
  loop: loopFromSearch(search, definition.loop === true),
129
+ ...(definition.pacing === undefined ? {} : { paceAuto: true }),
126
130
  up: viewUpVector(startViewUp(definition)),
127
131
  showMilkyWay: runtime.sky.milkyWay,
128
132
  bodyMarker: markerSettingsFromSearch(search),
@@ -145,8 +149,9 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
145
149
  /**
146
150
  * `onOpenAddress`: the entry's way to open a switch's address in place; without it a switch navigates the page.
147
151
  * `writeTitle`: whether the page heading is set to the experience's name (default true); `mount` and `AstraeusScene` pass false so a host page keeps its own title.
152
+ * `host`: the link a host page reads and sets the one clock through (time, speed) and hears its changes from; every change goes through the same handlers as the timeline's own controls.
148
153
  */
149
- export function App({ definition, onOpenAddress, writeTitle = true }) {
154
+ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
150
155
  // The page heading names the experience once it is open; app.html says only "Astraeus" until then.
151
156
  useEffect(() => {
152
157
  if (writeTitle)
@@ -261,15 +266,45 @@ export function App({ definition, onOpenAddress, writeTitle = true }) {
261
266
  controls.current.policy = scalePolicyFor(id, suppliedPolicies);
262
267
  setScale(id);
263
268
  }, [suppliedPolicies]);
269
+ const stateNow = useCallback(() => ({ ...runtime.clock.snapshot(), ...(runtime.pacing === undefined ? {} : { auto: controls.current.paceAuto === true }) }), [runtime]);
264
270
  useEffect(() => {
265
271
  const id = window.setInterval(() => {
266
272
  // The readout wraps with the scene, so the shown time never rests past the end while looping.
267
273
  if (controls.current.loop === true)
268
274
  runtime.clock.wrapWithin(runtime.loopWindow);
275
+ else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
276
+ runtime.clock.stopWithin(runtime.loopWindow);
277
+ if (controls.current.paceAuto === true && runtime.pacing !== undefined)
278
+ applyPacing(runtime.clock, runtime.pacing);
269
279
  setClockSnapshot(runtime.clock.snapshot());
280
+ host?.publish(stateNow(), "playback");
270
281
  }, 100);
271
282
  return () => window.clearInterval(id);
283
+ }, [runtime, host, stateNow]);
284
+ // The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
285
+ const seekTo = useCallback((timeUtcMs) => {
286
+ runtime.clock.seek(timeUtcMs);
287
+ setClockSnapshot(runtime.clock.snapshot());
288
+ }, [runtime]);
289
+ // A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
290
+ const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
291
+ const changeRate = useCallback((rate) => {
292
+ if (rate === "auto") {
293
+ if (runtime.pacing !== undefined)
294
+ applyPacing(runtime.clock, runtime.pacing);
295
+ }
296
+ else
297
+ runtime.clock.setRate(rate);
298
+ controls.current.paceAuto = rate === "auto";
299
+ setPaceAuto(rate === "auto");
300
+ setClockSnapshot(runtime.clock.snapshot());
272
301
  }, [runtime]);
302
+ useEffect(() => {
303
+ if (host === undefined)
304
+ return undefined;
305
+ host.attach({ window: runtime.loopWindow, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate });
306
+ return () => host.detach();
307
+ }, [host, runtime, definition, seekTo, changeRate]);
273
308
  useEffect(() => {
274
309
  if (!developerMode)
275
310
  return undefined;
@@ -385,17 +420,18 @@ export function App({ definition, onOpenAddress, writeTitle = true }) {
385
420
  ];
386
421
  const presentGroups = groups.filter((group) => group !== null);
387
422
  const developerTools = (_jsx(PanelLoadBoundary, { children: _jsx(Suspense, { fallback: _jsx("p", { className: "developer-loading", role: "status", children: "Loading developer tools..." }), children: _jsxs("div", { className: "hud", children: [_jsxs("header", { className: "developer-heading", children: [_jsx("h2", { children: "Developer tools" }), _jsx("p", { children: "Live readouts, controls and diagnostics for this scene." })] }), presentGroups.map((group, index) => (_jsx(Collapsible, { id: group.id, title: group.title, defaultOpen: index === 0, className: `dev-group${group.className === undefined ? "" : ` ${group.className}`}`, children: group.body }, group.id)))] }) }) }));
388
- return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
423
+ return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
389
424
  if (runtime.clock.playing)
390
425
  runtime.clock.pause();
391
426
  else
392
427
  runtime.clock.play();
393
428
  setClockSnapshot(runtime.clock.snapshot());
429
+ host?.publish(stateNow(), "visitor");
394
430
  }, onRateChange: (rate) => {
395
- runtime.clock.setRate(rate);
396
- setClockSnapshot(runtime.clock.snapshot());
431
+ changeRate(rate);
432
+ host?.publish(stateNow(), "visitor");
397
433
  }, onSeek: (timeUtcMs) => {
398
- runtime.clock.seek(timeUtcMs);
399
- setClockSnapshot(runtime.clock.snapshot());
434
+ seekTo(timeUtcMs);
435
+ host?.publish(stateNow(), "visitor");
400
436
  }, onCameraRequest: updateCameraRequest, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
401
437
  }
@@ -2,6 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
4
4
  import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
5
+ import { applyPacing } from "../core/pacing.js";
5
6
  import { openClock } from "./openClock.js";
6
7
  import { createSolarSystemScale } from "../core/scalePolicy.js";
7
8
  import { bodySetsOf, cameraReachOf, catalogueOf, compositionOf, experienceWithGroups, groupsOf, initialObjectIdOf, mountedBodiesOf, pageTitleOf, scaleChoiceIdsOf, sceneCenterOf, sunCentredOf, trackedBodiesOf, visualOverridesOf } from "./experienceDefinition.js";
@@ -106,6 +107,8 @@ function buildRuntime(definition) {
106
107
  cameraReach: cameraReachOf(definition),
107
108
  sky: skySettingsOf(definition),
108
109
  loopWindow: definition.experience.window,
110
+ ...(definition.experience.hideTimeline === true ? {} : { stopAtWindow: true }),
111
+ ...(definition.pacing === undefined ? {} : { pacing: definition.pacing }),
109
112
  up: viewUpVector(startViewUp(definition)),
110
113
  };
111
114
  }
@@ -123,6 +126,7 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
123
126
  cameraRequest: null,
124
127
  showAnchorLabels: labelStart(definition) === true && runtime.trackedBodies.length > 0,
125
128
  loop: loopFromSearch(search, definition.loop === true),
129
+ ...(definition.pacing === undefined ? {} : { paceAuto: true }),
126
130
  up: viewUpVector(startViewUp(definition)),
127
131
  showMilkyWay: runtime.sky.milkyWay,
128
132
  bodyMarker: markerSettingsFromSearch(search),
@@ -145,8 +149,9 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
145
149
  /**
146
150
  * `onOpenAddress`: the entry's way to open a switch's address in place; without it a switch navigates the page.
147
151
  * `writeTitle`: whether the page heading is set to the experience's name (default true); `mount` and `AstraeusScene` pass false so a host page keeps its own title.
152
+ * `host`: the link a host page reads and sets the one clock through (time, speed) and hears its changes from; every change goes through the same handlers as the timeline's own controls.
148
153
  */
149
- export function App({ definition, onOpenAddress, writeTitle = true }) {
154
+ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
150
155
  // The page heading names the experience once it is open; app.html says only "Astraeus" until then.
151
156
  useEffect(() => {
152
157
  if (writeTitle)
@@ -261,15 +266,45 @@ export function App({ definition, onOpenAddress, writeTitle = true }) {
261
266
  controls.current.policy = scalePolicyFor(id, suppliedPolicies);
262
267
  setScale(id);
263
268
  }, [suppliedPolicies]);
269
+ const stateNow = useCallback(() => ({ ...runtime.clock.snapshot(), ...(runtime.pacing === undefined ? {} : { auto: controls.current.paceAuto === true }) }), [runtime]);
264
270
  useEffect(() => {
265
271
  const id = window.setInterval(() => {
266
272
  // The readout wraps with the scene, so the shown time never rests past the end while looping.
267
273
  if (controls.current.loop === true)
268
274
  runtime.clock.wrapWithin(runtime.loopWindow);
275
+ else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
276
+ runtime.clock.stopWithin(runtime.loopWindow);
277
+ if (controls.current.paceAuto === true && runtime.pacing !== undefined)
278
+ applyPacing(runtime.clock, runtime.pacing);
269
279
  setClockSnapshot(runtime.clock.snapshot());
280
+ host?.publish(stateNow(), "playback");
270
281
  }, 100);
271
282
  return () => window.clearInterval(id);
283
+ }, [runtime, host, stateNow]);
284
+ // The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
285
+ const seekTo = useCallback((timeUtcMs) => {
286
+ runtime.clock.seek(timeUtcMs);
287
+ setClockSnapshot(runtime.clock.snapshot());
288
+ }, [runtime]);
289
+ // A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
290
+ const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
291
+ const changeRate = useCallback((rate) => {
292
+ if (rate === "auto") {
293
+ if (runtime.pacing !== undefined)
294
+ applyPacing(runtime.clock, runtime.pacing);
295
+ }
296
+ else
297
+ runtime.clock.setRate(rate);
298
+ controls.current.paceAuto = rate === "auto";
299
+ setPaceAuto(rate === "auto");
300
+ setClockSnapshot(runtime.clock.snapshot());
272
301
  }, [runtime]);
302
+ useEffect(() => {
303
+ if (host === undefined)
304
+ return undefined;
305
+ host.attach({ window: runtime.loopWindow, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate });
306
+ return () => host.detach();
307
+ }, [host, runtime, definition, seekTo, changeRate]);
273
308
  useEffect(() => {
274
309
  if (!developerMode)
275
310
  return undefined;
@@ -385,17 +420,18 @@ export function App({ definition, onOpenAddress, writeTitle = true }) {
385
420
  ];
386
421
  const presentGroups = groups.filter((group) => group !== null);
387
422
  const developerTools = (_jsx(PanelLoadBoundary, { children: _jsx(Suspense, { fallback: _jsx("p", { className: "developer-loading", role: "status", children: "Loading developer tools..." }), children: _jsxs("div", { className: "hud", children: [_jsxs("header", { className: "developer-heading", children: [_jsx("h2", { children: "Developer tools" }), _jsx("p", { children: "Live readouts, controls and diagnostics for this scene." })] }), presentGroups.map((group, index) => (_jsx(Collapsible, { id: group.id, title: group.title, defaultOpen: index === 0, className: `dev-group${group.className === undefined ? "" : ` ${group.className}`}`, children: group.body }, group.id)))] }) }) }));
388
- return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
423
+ return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
389
424
  if (runtime.clock.playing)
390
425
  runtime.clock.pause();
391
426
  else
392
427
  runtime.clock.play();
393
428
  setClockSnapshot(runtime.clock.snapshot());
429
+ host?.publish(stateNow(), "visitor");
394
430
  }, onRateChange: (rate) => {
395
- runtime.clock.setRate(rate);
396
- setClockSnapshot(runtime.clock.snapshot());
431
+ changeRate(rate);
432
+ host?.publish(stateNow(), "visitor");
397
433
  }, onSeek: (timeUtcMs) => {
398
- runtime.clock.seek(timeUtcMs);
399
- setClockSnapshot(runtime.clock.snapshot());
434
+ seekTo(timeUtcMs);
435
+ host?.publish(stateNow(), "visitor");
400
436
  }, onCameraRequest: updateCameraRequest, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
401
437
  }
@@ -1,4 +1,5 @@
1
1
  import type { SimulationClock } from "../core/clock.js";
2
+ import type { Pacing } from "../core/pacing.js";
2
3
  import type { BodyId } from "../core/body.js";
3
4
  import type { ScalePolicy } from "../core/scalePolicy.js";
4
5
  import type { StateResolver } from "../core/stateResolver.js";
@@ -27,7 +28,11 @@ export interface SceneRuntime {
27
28
  readonly startUtcMs: number;
28
29
  readonly endUtcMs: number;
29
30
  };
31
+ /** Playback stops on the edge of `loopWindow` when it runs past it (a scene with a timeline bar that does not loop); absent: the clock runs on. */
32
+ readonly stopAtWindow?: boolean;
30
33
  readonly clock: SimulationClock;
34
+ /** Paced playback (see `pacedRate`); absent: the clock keeps the rate it was given. */
35
+ readonly pacing?: Pacing;
31
36
  /** The one resolver every position in the scene comes from. */
32
37
  readonly resolver: StateResolver;
33
38
  /** The catalogue the bodies come from; absent means the built-in one. */
@@ -88,6 +93,8 @@ export interface SceneControls {
88
93
  illuminateAll: boolean;
89
94
  /** Looping playback is on (live; set from the experience, `?loop=` and Developer > Display settings). Needs `SceneRuntime.loopWindow`. */
90
95
  loop?: boolean;
96
+ /** Paced playback is in charge of the rate (live): true until a visitor or the host picks a speed, true again when they choose Auto. Meaningful with `SceneRuntime.pacing`. */
97
+ paceAuto?: boolean;
91
98
  /** The render-frame up vector now in force (live; Developer > Display settings). Absent: the runtime's own. Switching it re-poses the camera in place. */
92
99
  up?: RenderVector;
93
100
  /** Ids of objects whose label is switched off (live). Their objects stay listed and selectable. */
@@ -1,7 +1,8 @@
1
1
  // The members of a body set as one batch of dots (one draw call, like the showers' points) and one batch of balls (an instanced sphere,
2
2
  // one draw call). A dot has a pixel floor, so a member never vanishes; the ball is the member at its true size and is drawn with the depth
3
3
  // test, so once it is wider on screen than the dot it covers the dot (the dot sits at the ball's centre, behind its near surface).
4
- import { AmbientLight, BufferAttribute, BufferGeometry, Color, DirectionalLight, Group, InstancedBufferAttribute, InstancedMesh, Matrix4, MeshLambertMaterial, Points, PointsMaterial, SphereGeometry, Vector3, } from "three";
4
+ import { AmbientLight, BufferAttribute, BufferGeometry, Color, DirectionalLight, Group, InstancedBufferAttribute, InstancedMesh, Matrix4, MeshLambertMaterial, Points, SphereGeometry, Vector3, } from "three";
5
+ import { dotMaterial } from "./dotMaterial.js";
5
6
  import { projectedRadiusPx } from "./bodyDraw.js";
6
7
  import { bodyLightDirections } from "./lighting.js";
7
8
  import { eqjToRenderVector } from "./renderCoordinates.js";
@@ -47,7 +48,7 @@ export class BodySetView {
47
48
  // Each dot and ball carries its own colour, so a lit family can differ from the rest; the material colour stays white.
48
49
  this.#colours = new BufferAttribute(new Float32Array(3 * n), 3);
49
50
  geometry.setAttribute("color", this.#colours);
50
- this.#pointMaterial = new PointsMaterial({ size: 3, sizeAttenuation: false, depthWrite: true, vertexColors: true });
51
+ this.#pointMaterial = dotMaterial({ size: 3, sizeAttenuation: false, depthWrite: true, vertexColors: true });
51
52
  this.#points = new Points(geometry, this.#pointMaterial);
52
53
  this.#points.frustumCulled = false;
53
54
  this.#points.layers.set(TRACK_LAYER);
@@ -1,4 +1,4 @@
1
- import { Points, PointsMaterial } from "three";
1
+ import { Points, type PointsMaterial } from "three";
2
2
  import type { KeplerElements } from "../core/keplerElements.js";
3
3
  export declare class KeplerPoints {
4
4
  #private;
@@ -1,6 +1,7 @@
1
1
  // Purpose: the drawn dots of an orbit group that the graphics chip positions every frame from each member's ellipse (see keplerShader).
2
2
  // Uploads the per-member numbers once; each frame only a handful of uniforms change.
3
- import { BufferAttribute, BufferGeometry, Points, PointsMaterial, Vector3 } from "three";
3
+ import { BufferAttribute, BufferGeometry, Points, Vector3 } from "three";
4
+ import { dotMaterial } from "./dotMaterial.js";
4
5
  import { KEPLER_ATTRIBUTES_GLSL, KEPLER_BEGIN_VERTEX_GLSL, createKeplerAttributes, epochWindowSeconds, keplerGlsl, keplerLocalF32, setKeplerEpoch, } from "./keplerShader.js";
5
6
  import { TRACK_LAYER } from "./TrackedBodyView.js";
6
7
  /** Largest `n dt` the fastest member may accumulate either side of the epoch; keeps the 32-bit phase error under ~1e-7 of a turn. */
@@ -27,7 +28,7 @@ export class KeplerPoints {
27
28
  geometry.setAttribute("keplerQ", new BufferAttribute(this.#attributes.axisQ, 3));
28
29
  this.#shape = new BufferAttribute(this.#attributes.shape, 3);
29
30
  geometry.setAttribute("keplerShape", this.#shape);
30
- this.material = new PointsMaterial({ color, size: sizePx, sizeAttenuation: false, transparent: true, opacity: 0.9, depthWrite: false });
31
+ this.material = dotMaterial({ color, size: sizePx, sizeAttenuation: false, transparent: true, opacity: 0.9, depthWrite: false });
31
32
  this.material.onBeforeCompile = (shader) => this.#placeInVertexShader(shader);
32
33
  this.material.customProgramCacheKey = () => "astraeus-points-kepler";
33
34
  this.points = new Points(geometry, this.material);
@@ -1,4 +1,5 @@
1
- import { BufferAttribute, BufferGeometry, Group, Points, PointsMaterial, Vector3 } from "three";
1
+ import { BufferAttribute, BufferGeometry, Group, Points, Vector3 } from "three";
2
+ import { dotMaterial } from "./dotMaterial.js";
2
3
  import { fillKeplerRangeKm } from "../core/keplerElements.js";
3
4
  import { KeplerPoints } from "./KeplerPoints.js";
4
5
  import { eqjToRenderVector } from "./renderCoordinates.js";
@@ -102,7 +103,7 @@ export class PointsView {
102
103
  this.#to = new BufferAttribute(new Float32Array(3 * count), 3);
103
104
  geometry.setAttribute("position", this.#from);
104
105
  geometry.setAttribute("positionTo", this.#to);
105
- this.#material = new PointsMaterial({
106
+ this.#material = dotMaterial({
106
107
  color: layer.color,
107
108
  size: layer.pointSizePx ?? DEFAULT_POINT_SIZE_PX,
108
109
  sizeAttenuation: false,