@johnmorrisdotca/wakusei-planets 0.66.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -1
- package/NOTICE.md +11 -0
- package/README.md +3 -3
- package/dist/body-physics.d.ts +114 -0
- package/dist/body-physics.js +162 -0
- package/dist/data/moon-catalogue.d.ts +1 -1
- package/dist/data/moon-catalogue.js +1 -1
- package/dist/data/places-added.d.ts +2 -0
- package/dist/data/places-added.js +2 -0
- package/dist/data/places-aliases.d.ts +1 -0
- package/dist/data/places-aliases.js +14 -0
- package/dist/data/places-planned.js +1 -1
- package/dist/data/places-search-67p.d.ts +1 -0
- package/dist/data/places-search-67p.js +3 -0
- package/dist/data/places-search-amalthea.d.ts +1 -0
- package/dist/data/places-search-amalthea.js +3 -0
- package/dist/data/places-search-ariel.d.ts +1 -0
- package/dist/data/places-search-ariel.js +3 -0
- package/dist/data/places-search-bennu.d.ts +1 -0
- package/dist/data/places-search-bennu.js +3 -0
- package/dist/data/places-search-bodies.d.ts +25 -0
- package/dist/data/places-search-bodies.js +125 -0
- package/dist/data/places-search-callisto.d.ts +1 -0
- package/dist/data/places-search-callisto.js +3 -0
- package/dist/data/places-search-ceres.d.ts +1 -0
- package/dist/data/places-search-ceres.js +3 -0
- package/dist/data/places-search-charon.d.ts +1 -0
- package/dist/data/places-search-charon.js +3 -0
- package/dist/data/places-search-dactyl.d.ts +1 -0
- package/dist/data/places-search-dactyl.js +3 -0
- package/dist/data/places-search-deimos.d.ts +1 -0
- package/dist/data/places-search-deimos.js +3 -0
- package/dist/data/places-search-didymos.d.ts +1 -0
- package/dist/data/places-search-didymos.js +3 -0
- package/dist/data/places-search-dimorphos.d.ts +1 -0
- package/dist/data/places-search-dimorphos.js +3 -0
- package/dist/data/places-search-dinkinesh.d.ts +1 -0
- package/dist/data/places-search-dinkinesh.js +3 -0
- package/dist/data/places-search-dione.d.ts +1 -0
- package/dist/data/places-search-dione.js +3 -0
- package/dist/data/places-search-donaldjohanson.d.ts +1 -0
- package/dist/data/places-search-donaldjohanson.js +3 -0
- package/dist/data/places-search-enceladus.d.ts +1 -0
- package/dist/data/places-search-enceladus.js +3 -0
- package/dist/data/places-search-epimetheus.d.ts +1 -0
- package/dist/data/places-search-epimetheus.js +3 -0
- package/dist/data/places-search-eros.d.ts +1 -0
- package/dist/data/places-search-eros.js +3 -0
- package/dist/data/places-search-europa.d.ts +1 -0
- package/dist/data/places-search-europa.js +3 -0
- package/dist/data/places-search-ganymede.d.ts +1 -0
- package/dist/data/places-search-ganymede.js +3 -0
- package/dist/data/places-search-gaspra.d.ts +1 -0
- package/dist/data/places-search-gaspra.js +3 -0
- package/dist/data/places-search-hyperion.d.ts +1 -0
- package/dist/data/places-search-hyperion.js +3 -0
- package/dist/data/places-search-iapetus.d.ts +1 -0
- package/dist/data/places-search-iapetus.js +3 -0
- package/dist/data/places-search-ida.d.ts +1 -0
- package/dist/data/places-search-ida.js +3 -0
- package/dist/data/places-search-io.d.ts +1 -0
- package/dist/data/places-search-io.js +3 -0
- package/dist/data/places-search-itokawa.d.ts +1 -0
- package/dist/data/places-search-itokawa.js +3 -0
- package/dist/data/places-search-janus.d.ts +1 -0
- package/dist/data/places-search-janus.js +3 -0
- package/dist/data/places-search-jupiter.d.ts +1 -0
- package/dist/data/places-search-jupiter.js +3 -0
- package/dist/data/places-search-lutetia.d.ts +1 -0
- package/dist/data/places-search-lutetia.js +3 -0
- package/dist/data/places-search-mars.d.ts +1 -0
- package/dist/data/places-search-mars.js +3 -0
- package/dist/data/places-search-mathilde.d.ts +1 -0
- package/dist/data/places-search-mathilde.js +3 -0
- package/dist/data/places-search-mercury.d.ts +1 -0
- package/dist/data/places-search-mercury.js +3 -0
- package/dist/data/places-search-mimas.d.ts +1 -0
- package/dist/data/places-search-mimas.js +3 -0
- package/dist/data/places-search-miranda.d.ts +1 -0
- package/dist/data/places-search-miranda.js +3 -0
- package/dist/data/places-search-moon-satellites.d.ts +1 -0
- package/dist/data/places-search-moon-satellites.js +3 -0
- package/dist/data/places-search-moon.d.ts +1 -0
- package/dist/data/places-search-moon.js +3 -0
- package/dist/data/places-search-oberon.d.ts +1 -0
- package/dist/data/places-search-oberon.js +3 -0
- package/dist/data/places-search-phobos.d.ts +1 -0
- package/dist/data/places-search-phobos.js +3 -0
- package/dist/data/places-search-phoebe.d.ts +1 -0
- package/dist/data/places-search-phoebe.js +3 -0
- package/dist/data/places-search-pluto.d.ts +1 -0
- package/dist/data/places-search-pluto.js +3 -0
- package/dist/data/places-search-proteus.d.ts +1 -0
- package/dist/data/places-search-proteus.js +3 -0
- package/dist/data/places-search-rhea.d.ts +1 -0
- package/dist/data/places-search-rhea.js +3 -0
- package/dist/data/places-search-ryugu.d.ts +1 -0
- package/dist/data/places-search-ryugu.js +3 -0
- package/dist/data/places-search-saturn.d.ts +1 -0
- package/dist/data/places-search-saturn.js +3 -0
- package/dist/data/places-search-steins.d.ts +1 -0
- package/dist/data/places-search-steins.js +3 -0
- package/dist/data/places-search-tempel-1.d.ts +1 -0
- package/dist/data/places-search-tempel-1.js +3 -0
- package/dist/data/places-search-tethys.d.ts +1 -0
- package/dist/data/places-search-tethys.js +3 -0
- package/dist/data/places-search-thebe.d.ts +1 -0
- package/dist/data/places-search-thebe.js +3 -0
- package/dist/data/places-search-titan.d.ts +1 -0
- package/dist/data/places-search-titan.js +3 -0
- package/dist/data/places-search-titania.d.ts +1 -0
- package/dist/data/places-search-titania.js +3 -0
- package/dist/data/places-search-triton.d.ts +1 -0
- package/dist/data/places-search-triton.js +3 -0
- package/dist/data/places-search-types.d.ts +1 -0
- package/dist/data/places-search-types.js +59 -0
- package/dist/data/places-search-umbriel.d.ts +1 -0
- package/dist/data/places-search-umbriel.js +3 -0
- package/dist/data/places-search-venus.d.ts +1 -0
- package/dist/data/places-search-venus.js +3 -0
- package/dist/data/places-search-vesta.d.ts +1 -0
- package/dist/data/places-search-vesta.js +3 -0
- package/dist/fact-sheets.d.ts +1 -1
- package/dist/fact-sheets.js +1 -1
- package/dist/flat/words.js +2 -0
- package/dist/moon-catalogue.d.ts +190 -0
- package/dist/moon-catalogue.js +189 -3
- package/dist/place-marks.js +1 -1
- package/dist/place-search.d.ts +157 -0
- package/dist/place-search.js +198 -0
- package/dist/places/moon.js +4 -1
- package/dist/places/search/67p.d.ts +12 -0
- package/dist/places/search/67p.js +14 -0
- package/dist/places/search/amalthea.d.ts +12 -0
- package/dist/places/search/amalthea.js +14 -0
- package/dist/places/search/ariel.d.ts +12 -0
- package/dist/places/search/ariel.js +14 -0
- package/dist/places/search/bennu.d.ts +12 -0
- package/dist/places/search/bennu.js +14 -0
- package/dist/places/search/callisto.d.ts +12 -0
- package/dist/places/search/callisto.js +14 -0
- package/dist/places/search/ceres.d.ts +12 -0
- package/dist/places/search/ceres.js +14 -0
- package/dist/places/search/charon.d.ts +12 -0
- package/dist/places/search/charon.js +14 -0
- package/dist/places/search/dactyl.d.ts +12 -0
- package/dist/places/search/dactyl.js +14 -0
- package/dist/places/search/deimos.d.ts +12 -0
- package/dist/places/search/deimos.js +14 -0
- package/dist/places/search/didymos.d.ts +12 -0
- package/dist/places/search/didymos.js +14 -0
- package/dist/places/search/dimorphos.d.ts +12 -0
- package/dist/places/search/dimorphos.js +14 -0
- package/dist/places/search/dinkinesh.d.ts +12 -0
- package/dist/places/search/dinkinesh.js +14 -0
- package/dist/places/search/dione.d.ts +12 -0
- package/dist/places/search/dione.js +14 -0
- package/dist/places/search/donaldjohanson.d.ts +12 -0
- package/dist/places/search/donaldjohanson.js +14 -0
- package/dist/places/search/enceladus.d.ts +12 -0
- package/dist/places/search/enceladus.js +14 -0
- package/dist/places/search/epimetheus.d.ts +12 -0
- package/dist/places/search/epimetheus.js +14 -0
- package/dist/places/search/eros.d.ts +12 -0
- package/dist/places/search/eros.js +14 -0
- package/dist/places/search/europa.d.ts +12 -0
- package/dist/places/search/europa.js +14 -0
- package/dist/places/search/ganymede.d.ts +12 -0
- package/dist/places/search/ganymede.js +14 -0
- package/dist/places/search/gaspra.d.ts +12 -0
- package/dist/places/search/gaspra.js +14 -0
- package/dist/places/search/hyperion.d.ts +12 -0
- package/dist/places/search/hyperion.js +14 -0
- package/dist/places/search/iapetus.d.ts +12 -0
- package/dist/places/search/iapetus.js +14 -0
- package/dist/places/search/ida.d.ts +12 -0
- package/dist/places/search/ida.js +14 -0
- package/dist/places/search/io.d.ts +12 -0
- package/dist/places/search/io.js +14 -0
- package/dist/places/search/itokawa.d.ts +12 -0
- package/dist/places/search/itokawa.js +14 -0
- package/dist/places/search/janus.d.ts +12 -0
- package/dist/places/search/janus.js +14 -0
- package/dist/places/search/jupiter.d.ts +12 -0
- package/dist/places/search/jupiter.js +14 -0
- package/dist/places/search/lutetia.d.ts +12 -0
- package/dist/places/search/lutetia.js +14 -0
- package/dist/places/search/mars.d.ts +12 -0
- package/dist/places/search/mars.js +14 -0
- package/dist/places/search/mathilde.d.ts +12 -0
- package/dist/places/search/mathilde.js +14 -0
- package/dist/places/search/mercury.d.ts +12 -0
- package/dist/places/search/mercury.js +14 -0
- package/dist/places/search/mimas.d.ts +12 -0
- package/dist/places/search/mimas.js +14 -0
- package/dist/places/search/miranda.d.ts +12 -0
- package/dist/places/search/miranda.js +14 -0
- package/dist/places/search/moon-satellites.d.ts +12 -0
- package/dist/places/search/moon-satellites.js +14 -0
- package/dist/places/search/moon.d.ts +12 -0
- package/dist/places/search/moon.js +14 -0
- package/dist/places/search/oberon.d.ts +12 -0
- package/dist/places/search/oberon.js +14 -0
- package/dist/places/search/phobos.d.ts +12 -0
- package/dist/places/search/phobos.js +14 -0
- package/dist/places/search/phoebe.d.ts +12 -0
- package/dist/places/search/phoebe.js +14 -0
- package/dist/places/search/pluto.d.ts +12 -0
- package/dist/places/search/pluto.js +14 -0
- package/dist/places/search/proteus.d.ts +12 -0
- package/dist/places/search/proteus.js +14 -0
- package/dist/places/search/rhea.d.ts +12 -0
- package/dist/places/search/rhea.js +14 -0
- package/dist/places/search/ryugu.d.ts +12 -0
- package/dist/places/search/ryugu.js +14 -0
- package/dist/places/search/saturn.d.ts +12 -0
- package/dist/places/search/saturn.js +14 -0
- package/dist/places/search/steins.d.ts +12 -0
- package/dist/places/search/steins.js +14 -0
- package/dist/places/search/tempel-1.d.ts +12 -0
- package/dist/places/search/tempel-1.js +14 -0
- package/dist/places/search/tethys.d.ts +12 -0
- package/dist/places/search/tethys.js +14 -0
- package/dist/places/search/thebe.d.ts +12 -0
- package/dist/places/search/thebe.js +14 -0
- package/dist/places/search/titan.d.ts +12 -0
- package/dist/places/search/titan.js +14 -0
- package/dist/places/search/titania.d.ts +12 -0
- package/dist/places/search/titania.js +14 -0
- package/dist/places/search/triton.d.ts +12 -0
- package/dist/places/search/triton.js +14 -0
- package/dist/places/search/umbriel.d.ts +12 -0
- package/dist/places/search/umbriel.js +14 -0
- package/dist/places/search/venus.d.ts +12 -0
- package/dist/places/search/venus.js +14 -0
- package/dist/places/search/vesta.d.ts +12 -0
- package/dist/places/search/vesta.js +14 -0
- package/dist/places/search.d.ts +25 -0
- package/dist/places/search.js +28 -0
- package/dist/places.d.ts +4 -3
- package/dist/scene/place-layer.js +1 -0
- package/dist/space/all-moons.d.ts +81 -10
- package/dist/space/all-moons.js +132 -27
- package/dist/space/element.d.ts +31 -5
- package/dist/space/element.js +122 -23
- package/dist/space/moon-settings.d.ts +25 -0
- package/dist/space/moon-settings.js +43 -0
- package/dist/space/orbit-rules.d.ts +25 -0
- package/dist/space/orbit-rules.js +36 -0
- package/dist/space/scene.d.ts +9 -3
- package/dist/space/scene.js +27 -17
- package/dist/surface/element.d.ts +8 -0
- package/dist/surface/element.js +70 -15
- package/dist/surface/glide.d.ts +27 -0
- package/dist/surface/glide.js +43 -0
- package/dist/surface/glsl.d.ts +3 -3
- package/dist/surface/glsl.js +2 -1
- package/dist/surface/landing.d.ts +33 -0
- package/dist/surface/landing.js +26 -0
- package/package.json +276 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Which orbit lines the space view keeps, and which part of one it lets go, when a body is close (MODULES-1569). Pure: no DOM, no clock, no three.js.
|
|
2
|
+
/**
|
|
3
|
+
* Whether an orbit line belongs to the nearest body's own system, so that it is kept when that body is close: the body's own line (the Earth's, round the Sun, passes through the Earth) and, for the Earth and the Moon, the Moon's ring round the Earth.
|
|
4
|
+
*
|
|
5
|
+
* @param id - The body whose orbit line it is.
|
|
6
|
+
* @param nearId - The body that is close, the one the view is about.
|
|
7
|
+
* @returns True when the line is kept in a close view.
|
|
8
|
+
*/
|
|
9
|
+
export function isOwnLine(id, nearId) {
|
|
10
|
+
return id === nearId || (id === "moon" && (nearId === "earth" || nearId === "moon"));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whether the part of an orbit line near the close body is let go (faded out from 3 radii to 12), so that no line is drawn across the disc. Only a line that passes through the body needs it: a body's own line round the Sun, and the Moon's ring when it is the Moon that is close (the Moon
|
|
14
|
+
* is on it). The Moon's ring round the Earth does not pass through the Earth, and in the squeezed scale it lies 4 to 5 Earth radii out, inside the band, so fading it took the whole ring away when the Earth was close.
|
|
15
|
+
*
|
|
16
|
+
* @param id - The body whose orbit line it is.
|
|
17
|
+
* @param nearId - The body that is close.
|
|
18
|
+
* @param closeUp - Whether the close body's disc is big enough on the screen for the close view.
|
|
19
|
+
* @returns True when the line is faded near the body.
|
|
20
|
+
*/
|
|
21
|
+
export function fadesNearBody(id, nearId, closeUp) {
|
|
22
|
+
if (!closeUp || !isOwnLine(id, nearId))
|
|
23
|
+
return false;
|
|
24
|
+
// the Moon's ring round the Earth never meets the Earth
|
|
25
|
+
return !(id === "moon" && nearId === "earth");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How much of an orbit line's colour is kept at a point of it that is `away` radii of the close body from the body's middle: none within 3 radii and all from 12, a smooth step between.
|
|
29
|
+
*
|
|
30
|
+
* @param away - The distance from the body's middle, in the body's radii.
|
|
31
|
+
* @returns The share of the line's alpha, 0 to 1.
|
|
32
|
+
*/
|
|
33
|
+
export function nearBodyKeep(away) {
|
|
34
|
+
const t = Math.max(0, Math.min(1, (away - 3) / 9));
|
|
35
|
+
return t * t * (3 - 2 * t);
|
|
36
|
+
}
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type BodyId, type MoonId } from "../facts.ts";
|
|
|
4
4
|
import type { ThreeParts } from "../scene/body.ts";
|
|
5
5
|
import type { SourceBook } from "../door/book.ts";
|
|
6
6
|
import type { SmallBody } from "../door/small-bodies.ts";
|
|
7
|
-
import { type
|
|
7
|
+
import { type MoonColorChoice, type MoonSource, type MoonSpot } from "./all-moons.ts";
|
|
8
8
|
import { type BeltId } from "../belts/index.ts";
|
|
9
9
|
import { type PaintLabel, type WakuseiPainter } from "../scene/painter.ts";
|
|
10
10
|
import "../bodies/all.ts";
|
|
@@ -184,9 +184,14 @@ export interface SpaceModel {
|
|
|
184
184
|
anchor: number | null;
|
|
185
185
|
orbits: boolean;
|
|
186
186
|
labels: boolean;
|
|
187
|
-
/** The catalogue
|
|
188
|
-
|
|
187
|
+
/** The catalogue as a source of places and orbits, for the planets set to show all their moons (`moons`), or null for none (or before it has loaded); the planets chosen; what the orbits' colours say. */
|
|
188
|
+
moonSource: MoonSource | null;
|
|
189
|
+
moonHosts: ReadonlySet<string>;
|
|
190
|
+
moonColors: MoonColorChoice;
|
|
191
|
+
/** How many moon dots and orbits the last draw drew, and where the dots are on the screen (for a press). */
|
|
189
192
|
moonDots: number;
|
|
193
|
+
moonOrbits: number;
|
|
194
|
+
moonSpots: readonly MoonSpot[];
|
|
190
195
|
/** Milliseconds of game time one second of wall time covers (the ephemeris is looked up once per such span). */
|
|
191
196
|
stepMs: number;
|
|
192
197
|
/** Game seconds for each second of wall time, with its sign (0 when the clock holds): the places a move is worked out for are those the clock reaches by its end. */
|
|
@@ -251,6 +256,7 @@ export interface SpaceModel {
|
|
|
251
256
|
drawn: string[];
|
|
252
257
|
miss: Record<string, number>;
|
|
253
258
|
hidden: string[];
|
|
259
|
+
faded: string[];
|
|
254
260
|
};
|
|
255
261
|
/** The arrowheads on the orbit lines at the last draw, by line: where each is and the way it points. */
|
|
256
262
|
arrows: Record<string, OrbitArrow[]>;
|
package/dist/space/scene.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BODIES, MOONS_OF } from "../facts.js";
|
|
2
2
|
import { createSmallBodyPoints, smallBodyPlace } from "../door/points.js";
|
|
3
3
|
import { asteroidKey } from "./asteroid-ids.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createMoonLayer } from "./all-moons.js";
|
|
5
5
|
import { BELT_IDS, BELTS, OORT } from "../belts/index.js";
|
|
6
6
|
import { toTerrestrialTime } from "../clock.js";
|
|
7
7
|
import { moonOffset, orientation } from "../scene/orient.js";
|
|
@@ -20,6 +20,7 @@ import { createPaintOverlay } from "./paint-overlay.js";
|
|
|
20
20
|
import { createPaintTrail, groundUnder, paintMinute } from "../paint/trail.js";
|
|
21
21
|
import { BALL_FRAGMENT, VERTEX } from "../scene/glsl.js";
|
|
22
22
|
import { ridePose } from "./ride.js";
|
|
23
|
+
import { fadesNearBody, isOwnLine, nearBodyKeep } from "./orbit-rules.js";
|
|
23
24
|
import { moonDistance, moonSizeFactor, orbitLine, placeAround, placeBodies, placeMoon, radiusIn } from "./scale.js";
|
|
24
25
|
import { regionOrbits, regionView } from "./regions.js";
|
|
25
26
|
import { TRAVEL_BUDGET_MS, travelPlan, travelPose } from "./travel.js";
|
|
@@ -40,6 +41,9 @@ const ARROW_PX = 9;
|
|
|
40
41
|
const CLOSE_UP_PX = 30;
|
|
41
42
|
/** How long the Moon's ring is kept before it is worked out again from the Moon's place, in milliseconds: its path changes by a couple of hundred kilometres in that time. */
|
|
42
43
|
const MOON_RING_KEEP_MS = 5 * 86_400_000;
|
|
44
|
+
/** A source with no moon: what the moon layer is handed before the catalogue has loaded. */
|
|
45
|
+
const EMPTY_MOON_SOURCE = { moons: [], position: () => [0, 0, 0], orbit: () => [] };
|
|
46
|
+
const NO_HOSTS = new Set();
|
|
43
47
|
/** How many radii across the picture of a body is at zoom 1 when it has more than its globe: Saturn's rings (to 2.27 radii) are inside the view, not cut by it. */
|
|
44
48
|
const FRAMED = { saturn: 2.3 };
|
|
45
49
|
/** How much of the picture's shorter side a body's disc is framed across at zoom 1, in the body's radii: 1, and more for a ringed body. */
|
|
@@ -127,8 +131,12 @@ export const newSpaceModel = () => ({
|
|
|
127
131
|
anchor: null,
|
|
128
132
|
orbits: true,
|
|
129
133
|
labels: true,
|
|
130
|
-
|
|
134
|
+
moonSource: null,
|
|
135
|
+
moonHosts: new Set(),
|
|
136
|
+
moonColors: "group",
|
|
131
137
|
moonDots: 0,
|
|
138
|
+
moonOrbits: 0,
|
|
139
|
+
moonSpots: [],
|
|
132
140
|
stepMs: 1000,
|
|
133
141
|
speed: 1,
|
|
134
142
|
focus: "earth",
|
|
@@ -145,7 +153,7 @@ export const newSpaceModel = () => ({
|
|
|
145
153
|
drawn: null,
|
|
146
154
|
painted: { bodies: 0, moons: 0, held: 0 },
|
|
147
155
|
tiles: { requested: 0, loading: 0, failed: 0, shown: null },
|
|
148
|
-
rings: { drawn: [], miss: {}, hidden: [] },
|
|
156
|
+
rings: { drawn: [], miss: {}, hidden: [], faded: [] },
|
|
149
157
|
arrows: {},
|
|
150
158
|
help: false,
|
|
151
159
|
helpThrough: false,
|
|
@@ -252,10 +260,8 @@ export function createSpaceItem(model, deps) {
|
|
|
252
260
|
if (points !== undefined)
|
|
253
261
|
scene.add(points.object);
|
|
254
262
|
let pointsVersion = -1;
|
|
255
|
-
// the catalogue's
|
|
256
|
-
const
|
|
257
|
-
if (dots !== undefined)
|
|
258
|
-
scene.add(dots.object);
|
|
263
|
+
// the catalogue's moons of the planets set to `all`, as dots and orbits (a page's own subset of three needs Points, PointsMaterial, LineSegments and LineBasicMaterial for them)
|
|
264
|
+
const moonLayer = typeof three.Points === "function" && typeof three.LineSegments === "function" ? createMoonLayer(three, scene) : undefined;
|
|
259
265
|
let pointsBelts = null;
|
|
260
266
|
// the Oort cloud: three great circles at the shell's inner edge, drawn where the squeezed scale fits it (true to scale it is 2,000 astronomical units out, far past this view's reach)
|
|
261
267
|
const OORT_SEGMENTS = 96;
|
|
@@ -866,21 +872,24 @@ export function createSpaceItem(model, deps) {
|
|
|
866
872
|
}
|
|
867
873
|
}
|
|
868
874
|
}
|
|
869
|
-
if (
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
model.moonDots =
|
|
875
|
+
if (moonLayer !== undefined) {
|
|
876
|
+
const source = model.moonSource;
|
|
877
|
+
const drawn = moonLayer.update({ source: source ?? EMPTY_MOON_SOURCE, hosts: source === null ? NO_HOSTS : model.moonHosts, by: model.moonColors, mode, time: model.time, orbits: model.orbits, at: (host) => pos[host], radius: radiusOf, ratio: model.ratio(), spot: labelFor });
|
|
878
|
+
model.moonDots = drawn.dots;
|
|
879
|
+
model.moonOrbits = drawn.orbits;
|
|
880
|
+
model.moonSpots = drawn.spots;
|
|
873
881
|
}
|
|
874
882
|
// the orbits round the Sun, placed by the same mapping as the bodies
|
|
875
883
|
const drawnRings = [];
|
|
876
884
|
const hiddenRings = [];
|
|
885
|
+
const fadedRings = [];
|
|
877
886
|
const miss = {};
|
|
878
887
|
// Close to a body (its disc is a few dozen pixels across) the other orbit lines are seen edge-on, long straight scratches across it: only the lines of its own system are kept, and of those the part near it fades
|
|
879
888
|
const nearId = (rideFrom ? rideFrom.around : SPACE_BODIES.includes(focus) ? focus : (hostOf(focus) ?? "earth"));
|
|
880
889
|
const closeUp = px[nearId] >= CLOSE_UP_PX;
|
|
881
890
|
// flying through a belt (a point of the ride's own, round the Sun): the planets' orbit lines would be long scratches across the dots, so they are let go
|
|
882
891
|
const flying = rideFrom !== null && rideFrom.around === "sun" && typeof model.ride?.target !== "string";
|
|
883
|
-
const ownLine = (id) =>
|
|
892
|
+
const ownLine = (id) => isOwnLine(id, nearId);
|
|
884
893
|
const nearRadius = radiusOf(nearId);
|
|
885
894
|
for (const id of ORBIT_BODIES) {
|
|
886
895
|
const o = orbits.get(id);
|
|
@@ -902,12 +911,13 @@ export function createSpaceItem(model, deps) {
|
|
|
902
911
|
}
|
|
903
912
|
o.line.geometry.getAttribute("position").needsUpdate = true;
|
|
904
913
|
// the part of its own line near the body is let go, from 3 radii out to 12 (a close view sees a few radii across): never a line across the disc
|
|
905
|
-
const fade =
|
|
914
|
+
const fade = fadesNearBody(id, nearId, closeUp);
|
|
915
|
+
if (fade)
|
|
916
|
+
fadedRings.push(id);
|
|
906
917
|
if (fade || o.faded) {
|
|
907
918
|
for (let i = 0; i <= ORBIT_POINTS; i += 1) {
|
|
908
919
|
const away = Math.hypot(line[i][0] - pos[nearId][0], line[i][1] - pos[nearId][1], line[i][2] - pos[nearId][2]) / nearRadius;
|
|
909
|
-
|
|
910
|
-
o.colours[i * 4 + 3] = fade ? t * t * (3 - 2 * t) : 1;
|
|
920
|
+
o.colours[i * 4 + 3] = fade ? nearBodyKeep(away) : 1;
|
|
911
921
|
}
|
|
912
922
|
o.line.geometry.getAttribute("color").needsUpdate = true;
|
|
913
923
|
o.faded = fade;
|
|
@@ -920,7 +930,7 @@ export function createSpaceItem(model, deps) {
|
|
|
920
930
|
drawnRings.push(id);
|
|
921
931
|
miss[id] = distanceToLine(pos[id], line) / radius;
|
|
922
932
|
}
|
|
923
|
-
model.rings = { drawn: drawnRings, miss, hidden: hiddenRings };
|
|
933
|
+
model.rings = { drawn: drawnRings, miss, hidden: hiddenRings, faded: fadedRings };
|
|
924
934
|
// Starman and the Roadster: where the table puts the car, in the same mapping as the planets, as a dot a few pixels across, on its orbit line (about one trip round the Sun, from the table, worked out again every month)
|
|
925
935
|
const path = model.roadster ? model.roadsterPath : null;
|
|
926
936
|
let roadsterAt = null;
|
|
@@ -1427,7 +1437,7 @@ export function createSpaceItem(model, deps) {
|
|
|
1427
1437
|
},
|
|
1428
1438
|
dispose() {
|
|
1429
1439
|
points?.dispose();
|
|
1430
|
-
|
|
1440
|
+
moonLayer?.dispose();
|
|
1431
1441
|
oortGeometry.dispose();
|
|
1432
1442
|
oortLines.material.dispose();
|
|
1433
1443
|
paintOverlay?.dispose();
|
|
@@ -77,6 +77,7 @@ export declare class WakuseiSurface extends HTMLElement {
|
|
|
77
77
|
renderer: SharedRenderer<ThreeParts>["stats"] | undefined;
|
|
78
78
|
mesh: SurfaceScene["mesh"] | undefined;
|
|
79
79
|
quality: string;
|
|
80
|
+
gliding: boolean;
|
|
80
81
|
scale: number;
|
|
81
82
|
scaled: number;
|
|
82
83
|
landing: {
|
|
@@ -91,6 +92,13 @@ export declare class WakuseiSurface extends HTMLElement {
|
|
|
91
92
|
rocks: number;
|
|
92
93
|
vehicleDrawn: boolean;
|
|
93
94
|
};
|
|
95
|
+
/** Where the camera was in the last draw: the eye (metres east and north of the site, and its height) and the look; during a move it is the pose on the way, not where the view will end. `undefined` before the first draw. */
|
|
96
|
+
get camera(): {
|
|
97
|
+
east: number;
|
|
98
|
+
north: number;
|
|
99
|
+
up: number;
|
|
100
|
+
look: Look;
|
|
101
|
+
} | undefined;
|
|
94
102
|
connectedCallback(): void;
|
|
95
103
|
disconnectedCallback(): void;
|
|
96
104
|
attributeChangedCallback(name: string): void;
|
package/dist/surface/element.js
CHANGED
|
@@ -4,7 +4,7 @@ import { TILES_BASE } from "../scene/textures.js";
|
|
|
4
4
|
import { madeGround, rocksAround, setKeepOut, standingPlace } from "./detail.js";
|
|
5
5
|
import { driveStep, driveView, ROVER, startDrive, toWorld } from "./drive.js";
|
|
6
6
|
import { DustField } from "./dust.js";
|
|
7
|
-
import { calloutsBy, clockText, LANDING, landingAt } from "./landing.js";
|
|
7
|
+
import { calloutsBy, clockText, LANDING, landingAt, turnedBy, watchedLook } from "./landing.js";
|
|
8
8
|
import { drop, groundAt } from "./height.js";
|
|
9
9
|
import { loadTerrain } from "./load.js";
|
|
10
10
|
import { createSurfaceItem } from "./scene.js";
|
|
@@ -12,6 +12,7 @@ import { objectsOf, traverseOf } from "./objects.js";
|
|
|
12
12
|
import { standSky } from "./sky.js";
|
|
13
13
|
import { flatTerrain } from "./flat.js";
|
|
14
14
|
import { siteById } from "./site.js";
|
|
15
|
+
import { blendPose, easeInOut, GLIDE_MS } from "./glide.js";
|
|
15
16
|
import { clampLook, EYE_HEIGHT, stepOver, viewProjection, WALK_SPEED } from "./view.js";
|
|
16
17
|
export { setThreeLoader };
|
|
17
18
|
const TEMPLATE = `<style>
|
|
@@ -121,6 +122,10 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
121
122
|
#modelAbort;
|
|
122
123
|
#driveCamera = "chase";
|
|
123
124
|
#camOffset = { azimuth: 0, pitch: 0 };
|
|
125
|
+
/** The pose the last draw used, and whether it was the watched descent's (or a move from it still going): where a move to the standing view or the rover starts (MODULES-1561). */
|
|
126
|
+
#lastPose;
|
|
127
|
+
/** A smooth move of the camera in progress, from the pose it started at to wherever the view now puts it. */
|
|
128
|
+
#glide;
|
|
124
129
|
#driveEyeUp = 0;
|
|
125
130
|
#trail = [];
|
|
126
131
|
#dust = new DustField(900, 17);
|
|
@@ -184,14 +189,23 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
184
189
|
/** Numbers for a test or a status line: the draws, the tiles, the renderer's own counts, the mesh, the quality of the last draw and the milliseconds of the last measured one. */
|
|
185
190
|
get stats() {
|
|
186
191
|
const scene = this.#view?.scene;
|
|
187
|
-
return { state: this.#state, draws: this.#draws, tiles: this.#progress, renderer: this.#renderer?.stats, mesh: scene?.mesh, quality: this.#quality(), scale: this.#drawScale, scaled: this.#scaled, landing: this.landing, vehicle: this.#vehicle === undefined ? undefined : { ...this.#vehicle, spin: [...this.#vehicle.spin] }, drawMs: scene?.drawMs ?? this.#drawMs, rocks: scene?.rocks ?? 0, vehicleDrawn: scene?.vehicleDrawn ?? false };
|
|
192
|
+
return { state: this.#state, draws: this.#draws, tiles: this.#progress, renderer: this.#renderer?.stats, mesh: scene?.mesh, quality: this.#quality(), gliding: this.#glide !== undefined, scale: this.#drawScale, scaled: this.#scaled, landing: this.landing, vehicle: this.#vehicle === undefined ? undefined : { ...this.#vehicle, spin: [...this.#vehicle.spin] }, drawMs: scene?.drawMs ?? this.#drawMs, rocks: scene?.rocks ?? 0, vehicleDrawn: scene?.vehicleDrawn ?? false };
|
|
193
|
+
}
|
|
194
|
+
/** Where the camera was in the last draw: the eye (metres east and north of the site, and its height) and the look; during a move it is the pose on the way, not where the view will end. `undefined` before the first draw. */
|
|
195
|
+
get camera() {
|
|
196
|
+
const last = this.#lastPose?.pose;
|
|
197
|
+
return last === undefined ? undefined : { east: last.east, north: last.north, up: last.up, look: { ...last.look } };
|
|
198
|
+
}
|
|
199
|
+
/** Whether the draws are those of a view in motion: the view moved a moment ago, or the watched descent is running (its frames come every 33 ms, but a slow draw can leave the 160 ms of the last change behind: the frame after that was drawn at the quality of rest and the next at the quality of motion, and the ground flickered, MODULES-1547). */
|
|
200
|
+
#movingNow() {
|
|
201
|
+
return this.#moving || this.#landing?.playing === true;
|
|
188
202
|
}
|
|
189
203
|
/** The quality of the next draw: the `quality` attribute, or in `auto` the quality of motion while the view moves and the machine's own quality of rest otherwise. */
|
|
190
204
|
#quality() {
|
|
191
205
|
const own = this.getAttribute("quality");
|
|
192
206
|
if (own === "full" || own === "medium" || own === "fast")
|
|
193
207
|
return own;
|
|
194
|
-
return this.#
|
|
208
|
+
return this.#movingNow() ? "fast" : this.#restQuality;
|
|
195
209
|
}
|
|
196
210
|
connectedCallback() {
|
|
197
211
|
this.#root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
@@ -501,7 +515,8 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
501
515
|
// `auto`: a draw at rest is timed now and then, and a machine that takes too long at rest steps down (a card does a draw at full quality in a few milliseconds; a phone may not)
|
|
502
516
|
const auto = this.getAttribute("quality") === null || this.getAttribute("quality") === "auto";
|
|
503
517
|
const was = scene.drawMs;
|
|
504
|
-
|
|
518
|
+
const moving = this.#movingNow();
|
|
519
|
+
if (auto && !moving && was !== undefined && this.#measured > 0) {
|
|
505
520
|
if (was > 120 && this.#restQuality === "full")
|
|
506
521
|
this.#restQuality = "medium";
|
|
507
522
|
else if (was > 250 && this.#restQuality === "medium")
|
|
@@ -519,19 +534,46 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
519
534
|
}
|
|
520
535
|
}
|
|
521
536
|
const forced = scaleAttr === null || scaleAttr === "auto" ? undefined : Number(scaleAttr);
|
|
522
|
-
const timeMoving = auto &&
|
|
537
|
+
const timeMoving = auto && moving && this.#movingTimes.length < 4 && forced === undefined;
|
|
523
538
|
if (timeMoving)
|
|
524
539
|
this.#movingPending = true;
|
|
525
|
-
this.#drawScale = forced !== undefined && Number.isFinite(forced) ? Math.min(1, Math.max(0.25, forced)) :
|
|
526
|
-
const measure = (auto && !
|
|
527
|
-
if (measure && !
|
|
540
|
+
this.#drawScale = forced !== undefined && Number.isFinite(forced) ? Math.min(1, Math.max(0.25, forced)) : moving ? this.#moveScale : 1;
|
|
541
|
+
const measure = (auto && !moving && this.#measured < 4) || timeMoving;
|
|
542
|
+
if (measure && !moving)
|
|
528
543
|
this.#measured += 1;
|
|
529
544
|
if (this.#drawScale < 1)
|
|
530
545
|
this.#scaled += 1;
|
|
531
|
-
|
|
546
|
+
// the camera: where the view puts it, or on the way to there from where the watched descent had it (a move, not a cut)
|
|
547
|
+
let pose = { east: this.#at.east, north: this.#at.north, up: this.#eyeUp(), look: this.#look };
|
|
548
|
+
if (this.#glide !== undefined) {
|
|
549
|
+
const k = (performance.now() - this.#glide.at) / this.#glide.ms;
|
|
550
|
+
if (k >= 1)
|
|
551
|
+
this.#glide = undefined;
|
|
552
|
+
else
|
|
553
|
+
pose = blendPose(this.#glide.from, pose, easeInOut(k), (east, north) => this.#groundAt(east, north));
|
|
554
|
+
}
|
|
555
|
+
this.#lastPose = { pose, fromWatch: this.#landing !== undefined || this.#glide !== undefined };
|
|
556
|
+
scene.apply({ eye: { east: pose.east, north: pose.north, up: pose.up }, look: pose.look, sky: this.#sky, shadows: this.getAttribute("shadows") !== "off", detail: !this.#noDetail(), exposure: num(this.getAttribute("exposure"), this.#site()?.body === "mars" ? 1.5 : 1.6), quality: this.#quality(), scale: this.#drawScale, objects: this.#objects.length > 0, ...(this.#vehicle === undefined ? {} : { vehicle: this.#vehicle, ...(this.#model === undefined ? {} : { model: this.#model }), trail: this.#trail, dust: this.#dust.position }), ...(this.#landing === undefined ? {} : { lander: this.#landerState(), dust: this.#dust.position }), measure: measure || this.getAttribute("measure") !== null });
|
|
532
557
|
this.#view.invalidate();
|
|
533
558
|
this.#draws += 1;
|
|
534
559
|
this.#placeLabels();
|
|
560
|
+
// a move goes on a frame after a frame, at the quality of motion, until it arrives
|
|
561
|
+
if (this.#glide !== undefined)
|
|
562
|
+
this.#changed();
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Start a smooth move of the camera from where the last draw had it, when that was the watched descent's (or a move from it that has not arrived): to the standing view when the watch ends, to the rover when it starts to be driven, and to the other camera when the watch's camera (or where the ground camera stands) changes.
|
|
566
|
+
* The `glide` attribute is `off` for a cut, or the time in milliseconds (1100 by default); a reader who prefers reduced motion gets the cut.
|
|
567
|
+
*/
|
|
568
|
+
#beginGlide() {
|
|
569
|
+
const last = this.#lastPose;
|
|
570
|
+
const setting = this.getAttribute("glide");
|
|
571
|
+
if (last === undefined || !last.fromWatch || setting === "off")
|
|
572
|
+
return;
|
|
573
|
+
if (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
574
|
+
return;
|
|
575
|
+
const asked = Number(setting);
|
|
576
|
+
this.#glide = { from: last.pose, at: performance.now(), ms: setting !== null && Number.isFinite(asked) && asked > 0 ? asked : GLIDE_MS };
|
|
535
577
|
}
|
|
536
578
|
// --- driving the rover (`drive="on"`) ---------------------------------------------------------------------------------------------------------------
|
|
537
579
|
/** Which view of the rover: `chase` (from behind and above, the default) or `seat` (the commander's). The key C turns from one to the other. */
|
|
@@ -594,6 +636,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
594
636
|
this.choose(undefined);
|
|
595
637
|
this.#syncModel();
|
|
596
638
|
this.#syncDriveCamera();
|
|
639
|
+
this.#beginGlide();
|
|
597
640
|
this.#changed();
|
|
598
641
|
}
|
|
599
642
|
/** The vehicle's measures: a loaded model's, or the lunar rover's. */
|
|
@@ -868,6 +911,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
868
911
|
this.#readAttributes();
|
|
869
912
|
const td = this.#touchdown();
|
|
870
913
|
this.#at = { east: td.east, north: td.north };
|
|
914
|
+
this.#beginGlide();
|
|
871
915
|
this.#changed();
|
|
872
916
|
return;
|
|
873
917
|
}
|
|
@@ -880,9 +924,13 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
880
924
|
if (this.#landing.camera !== camera)
|
|
881
925
|
this.#look = clampLook({ ...this.#look, fov: camera === "ground" ? 27 : 74 });
|
|
882
926
|
const changed = this.#landing.camera !== camera;
|
|
927
|
+
// a change of camera, or of where the ground camera stands, is a move and not a cut (MODULES-1561)
|
|
928
|
+
const moved = changed || this.#landing.from.distance !== from.distance || this.#landing.from.bearing !== from.bearing;
|
|
883
929
|
this.#landing.camera = camera;
|
|
884
930
|
this.#landing.from = from;
|
|
885
931
|
this.#camOffset = { azimuth: 0, pitch: 0 };
|
|
932
|
+
if (moved)
|
|
933
|
+
this.#beginGlide();
|
|
886
934
|
this.#landingFrame(0, true);
|
|
887
935
|
if (changed)
|
|
888
936
|
this.#landingAnnounce();
|
|
@@ -940,7 +988,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
940
988
|
if (l.camera === "lander") {
|
|
941
989
|
this.#at = { east: lx, north: ly };
|
|
942
990
|
this.#landingEyeUp = lz + pose.altitude + 4;
|
|
943
|
-
this.#look = clampLook({ azimuth:
|
|
991
|
+
this.#look = clampLook({ ...watchedLook({ azimuth: pose.heading, pitch: pose.pitch }, this.#camOffset), fov: this.#look.fov });
|
|
944
992
|
}
|
|
945
993
|
else {
|
|
946
994
|
const b = (l.from.bearing * Math.PI) / 180;
|
|
@@ -950,7 +998,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
950
998
|
const horizontal = Math.hypot(lx - ox, ly - oy) || 1;
|
|
951
999
|
const azimuth = ((Math.atan2(lx - ox, ly - oy) * 180) / Math.PI + 360) % 360;
|
|
952
1000
|
const pitch = (Math.atan2(lz + pose.altitude + 3.4 - this.#landingEyeUp, horizontal) * 180) / Math.PI;
|
|
953
|
-
this.#look = clampLook({
|
|
1001
|
+
this.#look = clampLook({ ...watchedLook({ azimuth, pitch }, this.#camOffset), fov: this.#look.fov });
|
|
954
1002
|
}
|
|
955
1003
|
// the marker: while the stage is smaller than about 6 pixels in the ground camera a ring and its height mark where it is, fading out as it grows
|
|
956
1004
|
const ring = this.#root.getElementById("marker");
|
|
@@ -1180,6 +1228,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
1180
1228
|
};
|
|
1181
1229
|
// --- hands ---------------------------------------------------------------------------------------------------------------------------------------
|
|
1182
1230
|
#onPointerDown = (event) => {
|
|
1231
|
+
this.#glide = undefined;
|
|
1183
1232
|
this.#pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
|
|
1184
1233
|
this.setPointerCapture(event.pointerId);
|
|
1185
1234
|
this.setAttribute("data-dragging", "");
|
|
@@ -1199,10 +1248,15 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
1199
1248
|
}
|
|
1200
1249
|
const box = this.getBoundingClientRect();
|
|
1201
1250
|
const perPixel = this.#look.fov / Math.max(1, box.height);
|
|
1202
|
-
if (this.#vehicle !== undefined) {
|
|
1203
|
-
|
|
1204
|
-
this.#
|
|
1205
|
-
this.#
|
|
1251
|
+
if (this.#vehicle !== undefined || this.#landing !== undefined) {
|
|
1252
|
+
// the rover's camera and the watched descent's point themselves at every frame: a drag adds to a turn kept beside them (MODULES-1546: it was written into the look, which the next frame of the descent put back)
|
|
1253
|
+
this.#camOffset = turnedBy(this.#camOffset, event.clientX - was.x, event.clientY - was.y, perPixel);
|
|
1254
|
+
if (this.#vehicle !== undefined) {
|
|
1255
|
+
this.#syncDriveCamera();
|
|
1256
|
+
this.#changed();
|
|
1257
|
+
}
|
|
1258
|
+
else
|
|
1259
|
+
this.#landingFrame(0, false);
|
|
1206
1260
|
return;
|
|
1207
1261
|
}
|
|
1208
1262
|
this.#look = clampLook({ ...this.#look, azimuth: this.#look.azimuth - (event.clientX - was.x) * perPixel, pitch: this.#look.pitch + (event.clientY - was.y) * perPixel });
|
|
@@ -1229,6 +1283,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
1229
1283
|
this.#zoom(Math.exp(event.deltaY * 0.0015));
|
|
1230
1284
|
};
|
|
1231
1285
|
#onKeyDown = (event) => {
|
|
1286
|
+
this.#glide = undefined;
|
|
1232
1287
|
const key = event.key.length === 1 ? event.key.toLowerCase() : event.key;
|
|
1233
1288
|
if (key === "c" && this.#vehicle !== undefined) {
|
|
1234
1289
|
this.driveCamera = this.#driveCamera === "chase" ? "seat" : "chase";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Look } from "./view.ts";
|
|
2
|
+
/** How long the move takes by default, in milliseconds. */
|
|
3
|
+
export declare const GLIDE_MS = 1100;
|
|
4
|
+
/** Where the camera is and which way it looks: metres east and north of the site, the eye's height in metres (absolute, as the standing view's eye is), and the look. */
|
|
5
|
+
export interface Pose {
|
|
6
|
+
east: number;
|
|
7
|
+
north: number;
|
|
8
|
+
up: number;
|
|
9
|
+
look: Look;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The slow-fast-slow curve of the move: 0 at 0, 1 at 1, and flat at both ends so that it starts and stops without a jolt.
|
|
13
|
+
*
|
|
14
|
+
* @param t - How far through the move, 0 to 1 (outside is held).
|
|
15
|
+
* @returns The share of the way gone, 0 to 1.
|
|
16
|
+
*/
|
|
17
|
+
export declare function easeInOut(t: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* The pose a share `k` of the way from one pose to another: the eye on the straight line between them with its height above the ground blended (so it never goes under a hill between the two places), the azimuth the short way round, and the pitch and the field of view blended. At 0 it is `from` and at 1 it is `to`, exactly.
|
|
20
|
+
*
|
|
21
|
+
* @param from - Where the move starts.
|
|
22
|
+
* @param to - Where it ends.
|
|
23
|
+
* @param k - The share of the way, 0 to 1 (already eased).
|
|
24
|
+
* @param groundAt - The height of the ground at a place, in the same metres as `up`.
|
|
25
|
+
* @returns The blended pose.
|
|
26
|
+
*/
|
|
27
|
+
export declare function blendPose(from: Pose, to: Pose, k: number, groundAt: (east: number, north: number) => number): Pose;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** How long the move takes by default, in milliseconds. */
|
|
2
|
+
export const GLIDE_MS = 1100;
|
|
3
|
+
/**
|
|
4
|
+
* The slow-fast-slow curve of the move: 0 at 0, 1 at 1, and flat at both ends so that it starts and stops without a jolt.
|
|
5
|
+
*
|
|
6
|
+
* @param t - How far through the move, 0 to 1 (outside is held).
|
|
7
|
+
* @returns The share of the way gone, 0 to 1.
|
|
8
|
+
*/
|
|
9
|
+
export function easeInOut(t) {
|
|
10
|
+
const x = Math.max(0, Math.min(1, t));
|
|
11
|
+
return x * x * x * (x * (x * 6 - 15) + 10);
|
|
12
|
+
}
|
|
13
|
+
const turnBetween = (a, b) => ((((b - a) % 360) + 540) % 360) - 180;
|
|
14
|
+
/**
|
|
15
|
+
* The pose a share `k` of the way from one pose to another: the eye on the straight line between them with its height above the ground blended (so it never goes under a hill between the two places), the azimuth the short way round, and the pitch and the field of view blended. At 0 it is `from` and at 1 it is `to`, exactly.
|
|
16
|
+
*
|
|
17
|
+
* @param from - Where the move starts.
|
|
18
|
+
* @param to - Where it ends.
|
|
19
|
+
* @param k - The share of the way, 0 to 1 (already eased).
|
|
20
|
+
* @param groundAt - The height of the ground at a place, in the same metres as `up`.
|
|
21
|
+
* @returns The blended pose.
|
|
22
|
+
*/
|
|
23
|
+
export function blendPose(from, to, k, groundAt) {
|
|
24
|
+
if (!(k > 0))
|
|
25
|
+
return { ...from, look: { ...from.look } };
|
|
26
|
+
if (!(k < 1))
|
|
27
|
+
return { ...to, look: { ...to.look } };
|
|
28
|
+
const east = from.east + (to.east - from.east) * k;
|
|
29
|
+
const north = from.north + (to.north - from.north) * k;
|
|
30
|
+
const aboveFrom = from.up - groundAt(from.east, from.north);
|
|
31
|
+
const aboveTo = to.up - groundAt(to.east, to.north);
|
|
32
|
+
const up = groundAt(east, north) + aboveFrom + (aboveTo - aboveFrom) * k;
|
|
33
|
+
return {
|
|
34
|
+
east,
|
|
35
|
+
north,
|
|
36
|
+
up,
|
|
37
|
+
look: {
|
|
38
|
+
azimuth: (((from.look.azimuth + turnBetween(from.look.azimuth, to.look.azimuth) * k) % 360) + 360) % 360,
|
|
39
|
+
pitch: from.look.pitch + (to.look.pitch - from.look.pitch) * k,
|
|
40
|
+
fov: from.look.fov + (to.look.fov - from.look.fov) * k,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|