@johnmorrisdotca/wakusei-planets 0.36.0 → 0.37.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 +14 -0
- package/NOTICE.md +15 -1
- package/README.md +5 -4
- package/dist/data/moon-catalogue.d.ts +31 -0
- package/dist/data/moon-catalogue.js +471 -0
- package/dist/data/places-planned.d.ts +3 -0
- package/dist/data/places-planned.js +51 -0
- package/dist/element.d.ts +28 -0
- package/dist/element.js +178 -2
- package/dist/moon-catalogue.d.ts +296 -0
- package/dist/moon-catalogue.js +234 -0
- package/dist/place-marks.d.ts +182 -0
- package/dist/place-marks.js +194 -0
- package/dist/places/mars.d.ts +1 -1
- package/dist/places/mars.js +4 -2
- package/dist/places/moon.d.ts +1 -1
- package/dist/places/moon.js +4 -2
- package/dist/places.d.ts +4 -2
- package/dist/places.js +2 -0
- package/dist/scene/place-layer.d.ts +68 -0
- package/dist/scene/place-layer.js +213 -0
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/all-moons.d.ts +30 -0
- package/dist/space/all-moons.js +61 -0
- package/dist/space/bodies.d.ts +18 -0
- package/dist/space/bodies.js +18 -0
- package/dist/space/element.d.ts +102 -2
- package/dist/space/element.js +415 -7
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/scene.d.ts +32 -0
- package/dist/space/scene.js +44 -0
- package/dist/space/sight.d.ts +106 -0
- package/dist/space/sight.js +84 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const read = "2026-11-11";
|
|
2
|
+
const nasa = "https://www.nasa.gov/event/";
|
|
3
|
+
export const PLANNED_MOON = [
|
|
4
|
+
{
|
|
5
|
+
id: "moon/griffin-mission-one", kind: "planned", name: { en: "Griffin Mission One", ja: "グリフィン ミッション1" }, lat: -85.2752, lon: 53.2725, approximate: true, site: "Nobile",
|
|
6
|
+
mission: "Griffin-1 (CLPS TO20A)", operator: "Astrobotic", country: "US", planned: { date: "2026", status: "slipped", read, dateOf: "launch" },
|
|
7
|
+
source: { id: "announcement", read, url: `${nasa}clps-flight-astrobotics-griffin-mission-one/` },
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: "moon/im-3", kind: "planned", name: { en: "IM-3", ja: "IM-3" }, lat: 7.3853, lon: -58.9583, approximate: true, site: "Reiner Gamma",
|
|
11
|
+
mission: "IM-3 (CLPS CP-11)", operator: "Intuitive Machines", country: "US", planned: { date: "2027", status: "slipped", read, dateOf: "launch" },
|
|
12
|
+
source: { id: "announcement", read, url: `${nasa}clps-flight-intuitive-machines-im-3/` },
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "moon/blue-moon-mk1-endurance", kind: "planned", name: { en: "Blue Moon MK1 Endurance", ja: "ブルームーン MK1 エンデュランス" }, lat: -89.67, lon: 129.78, approximate: true, site: "Shackleton connecting ridge",
|
|
16
|
+
mission: "Blue Moon Mark 1 pathfinder", operator: "Blue Origin", country: "US", planned: { date: "2027", status: "announced", read, dateOf: "launch" },
|
|
17
|
+
source: { id: "announcement", read, url: `${nasa}clps-flight-blue-origins-blue-moon-mark-1/` },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "moon/im-4", kind: "planned", name: { en: "IM-4", ja: "IM-4" }, lat: -84.6, lon: 31, approximate: true, site: "Mons Mouton",
|
|
21
|
+
mission: "IM-4 (CLPS CP-22)", operator: "Intuitive Machines", country: "US", planned: { date: "2027", status: "announced", read, dateOf: "launch" },
|
|
22
|
+
source: { id: "announcement", read, url: `${nasa}clps-flight-intuitive-machines-im-4-2/` },
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "moon/blue-ghost-mission-2", kind: "planned", name: { en: "Blue Ghost Mission 2", ja: "ブルーゴースト ミッション2" }, lat: -24.9137, lon: 177.337, approximate: true, site: "Nassau",
|
|
26
|
+
mission: "Blue Ghost Mission 2 (CLPS CS-3/4)", operator: "Firefly Aerospace", country: "US", planned: { date: "2027", status: "slipped", read, dateOf: "launch" },
|
|
27
|
+
source: { id: "announcement", read, url: "https://fireflyspace.com/missions/blue-ghost-mission-2/" },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "moon/viper", kind: "planned", name: { en: "VIPER", ja: "VIPER" }, lat: -84.6, lon: 31, approximate: true, site: "Mons Mouton",
|
|
31
|
+
mission: "VIPER (CLPS CS-7)", operator: "NASA", country: "US", planned: { date: "2027", status: "announced", read, dateOf: "landing" },
|
|
32
|
+
source: { id: "announcement", read, url: "https://www.nasa.gov/moonbase-phases/" },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "moon/blue-ghost-mission-3", kind: "planned", name: { en: "Blue Ghost Mission 3", ja: "ブルーゴースト ミッション3" }, lat: 36.5585, lon: -40.7213, approximate: true, site: "Gruithuisen Domes",
|
|
36
|
+
mission: "Blue Ghost Mission 3 (CLPS CP-21)", operator: "Firefly Aerospace", country: "US", planned: { date: "2028", status: "announced", read, dateOf: "launch" },
|
|
37
|
+
source: { id: "announcement", read, url: "https://fireflyspace.com/missions/blue-ghost-mission-3/" },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "moon/blue-ghost-mission-4", kind: "planned", name: { en: "Blue Ghost Mission 4", ja: "ブルーゴースト ミッション4" }, lat: -87.45, lon: -5.17, approximate: true, site: "Haworth",
|
|
41
|
+
mission: "Blue Ghost Mission 4 (CLPS CS-6)", operator: "Firefly Aerospace", country: "US", planned: { date: "2029", status: "announced", read, dateOf: "launch" },
|
|
42
|
+
source: { id: "announcement", read, url: "https://fireflyspace.com/missions/blue-ghost-mission-4/" },
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
export const PLANNED_MARS = [
|
|
46
|
+
{
|
|
47
|
+
id: "mars/rosalind-franklin", kind: "planned", name: { en: "Rosalind Franklin", ja: "ロザリンド・フランクリン" }, lat: 17.28, lon: -25.71, approximate: true, site: "Oxia Planum",
|
|
48
|
+
mission: "ExoMars Rosalind Franklin", operator: "ESA", country: "EU", planned: { date: "2030", status: "announced", read, dateOf: "landing" },
|
|
49
|
+
source: { id: "announcement", read, latitude: "planetocentric", url: "https://www.esa.int/Science_Exploration/Human_and_Robotic_Exploration/Exploration/ExoMars/FAQ_The_rebirth_of_ESA_s_ExoMars_Rosalind_Franklin_mission" },
|
|
50
|
+
},
|
|
51
|
+
];
|
package/dist/element.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ import type { DetailStats } from "./scene/detail.ts";
|
|
|
10
10
|
import { type BodyScene, type ThreeParts } from "./scene/body.ts";
|
|
11
11
|
import { type NameLabelOptions } from "./scene/name-label.ts";
|
|
12
12
|
import { setThreeLoader } from "./scene/shared.ts";
|
|
13
|
+
import { type Place } from "./places.ts";
|
|
14
|
+
import { type PlaceLayer } from "./place-marks.ts";
|
|
13
15
|
export { setThreeLoader };
|
|
16
|
+
export { placeLine, setPlacesLoader } from "./scene/place-layer.ts";
|
|
14
17
|
/**
|
|
15
18
|
* What the element is doing: `line` (an SVG), `loading` (waiting for three.js or a picture), `still` (a picture of the 3D look, nothing running), `live` (drawing), `lost` (the GPU took the context; it comes back by itself) or `unavailable` (no WebGL: the line drawing is shown).
|
|
16
19
|
*
|
|
@@ -34,6 +37,7 @@ export type WakuseiState = "line" | "loading" | "still" | "live" | "lost" | "una
|
|
|
34
37
|
* `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
|
|
35
38
|
* Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
|
|
36
39
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
40
|
+
* `places` marks the places on the body in the shaded looks, by layer (`landing`, `crash`, `planned`, `feature`; the lists come from `setPlacesLoader`), with `wakusei-place` on a click and `goToPlace` to turn one to the middle: see the guide "Places on the Moon, Mars and 31 more bodies".
|
|
37
41
|
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font` and `-fallback-font` beside it, and the `bodyLabel` property takes the same as an object: see the guide "A name on the body".
|
|
38
42
|
* A dated picture (a `time`, or `moons`) has a clock: `rate` is the simulated seconds for each real second, and `rate="0"` holds it, drawing nothing. While it runs (`rate` not 0), `wakusei-timechange` carries
|
|
39
43
|
* `detail: { time, running: true }` (`time` is the moment shown in milliseconds since 1970; four times a second, once a second at real time; only while the tab is shown, whether or not the picture is on screen), and once with
|
|
@@ -91,6 +95,30 @@ export declare class WakuseiBody extends HTMLElement {
|
|
|
91
95
|
*/
|
|
92
96
|
get bodyLabel(): NameLabelOptions | null;
|
|
93
97
|
set bodyLabel(value: NameLabelOptions | null | undefined);
|
|
98
|
+
/**
|
|
99
|
+
* The layers of places marked on the body in the shaded looks: any of `landing` (the crewed landings, landers and rovers), `crash` (the crash, impact and atmospheric-entry sites), `planned` (announced landings) and
|
|
100
|
+
* `feature` (named features), from the `places` attribute (`places="landing crash"`; `places` alone or `all` for every layer). A body with no places (see `PLACE_BODIES` from `/places`) shows none. Setting it writes the attribute.
|
|
101
|
+
*/
|
|
102
|
+
get places(): PlaceLayer[];
|
|
103
|
+
set places(layers: readonly PlaceLayer[] | null);
|
|
104
|
+
/** The marks laid on the body now: each place's id, its layer and where its mark is, in CSS pixels from the picture's top left. */
|
|
105
|
+
get placesShown(): readonly {
|
|
106
|
+
id: string;
|
|
107
|
+
layer: PlaceLayer;
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
}[];
|
|
111
|
+
/**
|
|
112
|
+
* Turn the body so a place is in the middle of the disc, at a pace you can follow while the picture is live (at once for a still, for a reader who prefers reduced motion, or with `smooth: false`); the zoom stays. The place is an id (`moon/apollo-11-lunar-module`),
|
|
113
|
+
* or an English or Japanese name. A body that turns by itself carries the place on from there (`turn="0"` keeps it). Resolves the place, or `undefined` when the body has no place by that name.
|
|
114
|
+
*
|
|
115
|
+
* @param text - The place's id or name.
|
|
116
|
+
* @param options - `smooth` (true by default).
|
|
117
|
+
* @returns The place, once the turn has started.
|
|
118
|
+
*/
|
|
119
|
+
goToPlace(text: string, options?: {
|
|
120
|
+
smooth?: boolean;
|
|
121
|
+
}): Promise<Place | undefined>;
|
|
94
122
|
/** What the element is doing now. */
|
|
95
123
|
get state(): WakuseiState;
|
|
96
124
|
/** Numbers for a test or a status line: the state, the texture width in use and the renderer's own counts. */
|
package/dist/element.js
CHANGED
|
@@ -21,7 +21,11 @@ import { NAME_LABEL_ATTRIBUTES, nameLabelKey, nameLabelText, readNameLabel } fro
|
|
|
21
21
|
import { delegates, onRegister } from "./scene/store.js";
|
|
22
22
|
import { setThreeLoader, takeRenderer } from "./scene/shared.js";
|
|
23
23
|
import { turn as turnVec } from "./vec.js";
|
|
24
|
+
import { findPlace, PLACE_BODIES } from "./places.js";
|
|
25
|
+
import { placeMarks, readPlaceLayers, turnToPlace } from "./place-marks.js";
|
|
26
|
+
import { createPlaceLayer, onPlacesLoader, placesLoader } from "./scene/place-layer.js";
|
|
24
27
|
export { setThreeLoader };
|
|
28
|
+
export { placeLine, setPlacesLoader } from "./scene/place-layer.js";
|
|
25
29
|
const num = (value, fallback) => {
|
|
26
30
|
if (value === null || value.trim() === "")
|
|
27
31
|
return fallback;
|
|
@@ -79,6 +83,7 @@ const TEMPLATE = `<style>
|
|
|
79
83
|
* `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
|
|
80
84
|
* Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
|
|
81
85
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
86
|
+
* `places` marks the places on the body in the shaded looks, by layer (`landing`, `crash`, `planned`, `feature`; the lists come from `setPlacesLoader`), with `wakusei-place` on a click and `goToPlace` to turn one to the middle: see the guide "Places on the Moon, Mars and 31 more bodies".
|
|
82
87
|
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font` and `-fallback-font` beside it, and the `bodyLabel` property takes the same as an object: see the guide "A name on the body".
|
|
83
88
|
* A dated picture (a `time`, or `moons`) has a clock: `rate` is the simulated seconds for each real second, and `rate="0"` holds it, drawing nothing. While it runs (`rate` not 0), `wakusei-timechange` carries
|
|
84
89
|
* `detail: { time, running: true }` (`time` is the moment shown in milliseconds since 1970; four times a second, once a second at real time; only while the tab is shown, whether or not the picture is on screen), and once with
|
|
@@ -96,7 +101,7 @@ const TEMPLATE = `<style>
|
|
|
96
101
|
* ```
|
|
97
102
|
*/
|
|
98
103
|
export class WakuseiBody extends HTMLElement {
|
|
99
|
-
static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", ...NAME_LABEL_ATTRIBUTES];
|
|
104
|
+
static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", ...NAME_LABEL_ATTRIBUTES];
|
|
100
105
|
#stage;
|
|
101
106
|
#state = "line";
|
|
102
107
|
#renderer;
|
|
@@ -138,6 +143,12 @@ export class WakuseiBody extends HTMLElement {
|
|
|
138
143
|
#tileLevels;
|
|
139
144
|
#tiles;
|
|
140
145
|
#bodyLabel;
|
|
146
|
+
#placeLayer;
|
|
147
|
+
#placeList;
|
|
148
|
+
#placeLoading;
|
|
149
|
+
#placeGlide = 0;
|
|
150
|
+
#placeResize;
|
|
151
|
+
#placeHeard;
|
|
141
152
|
#door = createDoorHost(this, {
|
|
142
153
|
own: () => {
|
|
143
154
|
// the body's own pictures and, where a window of the package's own tiles is on it, those
|
|
@@ -257,6 +268,145 @@ export class WakuseiBody extends HTMLElement {
|
|
|
257
268
|
this.#lastAnchors = -1;
|
|
258
269
|
this.#queue();
|
|
259
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The layers of places marked on the body in the shaded looks: any of `landing` (the crewed landings, landers and rovers), `crash` (the crash, impact and atmospheric-entry sites), `planned` (announced landings) and
|
|
273
|
+
* `feature` (named features), from the `places` attribute (`places="landing crash"`; `places` alone or `all` for every layer). A body with no places (see `PLACE_BODIES` from `/places`) shows none. Setting it writes the attribute.
|
|
274
|
+
*/
|
|
275
|
+
get places() {
|
|
276
|
+
return readPlaceLayers(this.getAttribute("places"));
|
|
277
|
+
}
|
|
278
|
+
set places(layers) {
|
|
279
|
+
if (layers === null || layers.length === 0)
|
|
280
|
+
this.removeAttribute("places");
|
|
281
|
+
else
|
|
282
|
+
this.setAttribute("places", layers.join(" "));
|
|
283
|
+
}
|
|
284
|
+
/** The marks laid on the body now: each place's id, its layer and where its mark is, in CSS pixels from the picture's top left. */
|
|
285
|
+
get placesShown() {
|
|
286
|
+
return this.#placeLayer?.shown ?? [];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Turn the body so a place is in the middle of the disc, at a pace you can follow while the picture is live (at once for a still, for a reader who prefers reduced motion, or with `smooth: false`); the zoom stays. The place is an id (`moon/apollo-11-lunar-module`),
|
|
290
|
+
* or an English or Japanese name. A body that turns by itself carries the place on from there (`turn="0"` keeps it). Resolves the place, or `undefined` when the body has no place by that name.
|
|
291
|
+
*
|
|
292
|
+
* @param text - The place's id or name.
|
|
293
|
+
* @param options - `smooth` (true by default).
|
|
294
|
+
* @returns The place, once the turn has started.
|
|
295
|
+
*/
|
|
296
|
+
async goToPlace(text, options = {}) {
|
|
297
|
+
const list = await this.#loadPlaces();
|
|
298
|
+
const place = list === undefined ? undefined : findPlace(list, text);
|
|
299
|
+
if (place === undefined)
|
|
300
|
+
return undefined;
|
|
301
|
+
const frame = this.#frameNow();
|
|
302
|
+
const aim = turnToPlace(frame.pose.pole, frame.pose.meridian, place.lat, place.lon);
|
|
303
|
+
const to = { yaw: aim.yaw, tilt: this.#pitchDelta - aim.tilt };
|
|
304
|
+
const from = { yaw: this.#yaw, tilt: this.#tilt };
|
|
305
|
+
// the shorter way round
|
|
306
|
+
to.yaw = from.yaw + ((((to.yaw - from.yaw + 180) % 360) + 360) % 360) - 180;
|
|
307
|
+
const apply = (yaw, tilt, final) => {
|
|
308
|
+
const controller = this.#hands?.controller;
|
|
309
|
+
if (controller !== undefined && !this.hasAttribute("data-kazoku-bar"))
|
|
310
|
+
controller.set({ yaw, tilt }, final, "place");
|
|
311
|
+
else
|
|
312
|
+
this.setView({ yaw, tilt, roll: this.#roll, zoom: this.#zoom });
|
|
313
|
+
};
|
|
314
|
+
const glide = (this.#placeGlide += 1);
|
|
315
|
+
// a still (not live) is made again for every change of view: it goes there at once
|
|
316
|
+
if (options.smooth === false || this.#reduce || this.#view?.live !== true || typeof requestAnimationFrame !== "function") {
|
|
317
|
+
apply(to.yaw, to.tilt, true);
|
|
318
|
+
return place;
|
|
319
|
+
}
|
|
320
|
+
const start = performance.now();
|
|
321
|
+
const step = () => {
|
|
322
|
+
if (glide !== this.#placeGlide || !this.isConnected)
|
|
323
|
+
return;
|
|
324
|
+
const k = Math.min(1, (performance.now() - start) / 900);
|
|
325
|
+
const ease = k * k * (3 - 2 * k);
|
|
326
|
+
apply(from.yaw + (to.yaw - from.yaw) * ease, from.tilt + (to.tilt - from.tilt) * ease, k >= 1);
|
|
327
|
+
if (k < 1)
|
|
328
|
+
requestAnimationFrame(step);
|
|
329
|
+
};
|
|
330
|
+
requestAnimationFrame(step);
|
|
331
|
+
return place;
|
|
332
|
+
}
|
|
333
|
+
/** The body's list of places, loaded the first time it is asked for; `undefined` for a body that has none. */
|
|
334
|
+
async #loadPlaces() {
|
|
335
|
+
const body = this.body;
|
|
336
|
+
if (this.#placeList?.body === body)
|
|
337
|
+
return this.#placeList.list;
|
|
338
|
+
const load = placesLoader();
|
|
339
|
+
if (load === undefined || this.hasAttribute("star") || !PLACE_BODIES.includes(body))
|
|
340
|
+
return undefined;
|
|
341
|
+
const list = await load(body);
|
|
342
|
+
if (this.body === body)
|
|
343
|
+
this.#placeList = { body, list };
|
|
344
|
+
return list;
|
|
345
|
+
}
|
|
346
|
+
/** Lay the marks of the places over the picture as the scene state has it, or take them away. Draws nothing. */
|
|
347
|
+
#markPlaces(state = this.#sceneState) {
|
|
348
|
+
const layers = this.places;
|
|
349
|
+
const shaded = this.look !== "line" && this.#view !== undefined && !this.hasAttribute("star");
|
|
350
|
+
if (layers.length === 0 || !shaded || state === undefined) {
|
|
351
|
+
if (this.#placeLayer !== undefined) {
|
|
352
|
+
this.#placeLayer.dispose();
|
|
353
|
+
this.#placeLayer = undefined;
|
|
354
|
+
if (this.getAttribute("role") === "group")
|
|
355
|
+
this.setAttribute("role", "img");
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const body = this.body;
|
|
360
|
+
if (this.#placeList?.body !== body) {
|
|
361
|
+
if (this.#placeLoading !== body && placesLoader() !== undefined && PLACE_BODIES.includes(body)) {
|
|
362
|
+
this.#placeLoading = body;
|
|
363
|
+
void this.#loadPlaces().then(() => {
|
|
364
|
+
this.#placeLoading = undefined;
|
|
365
|
+
if (this.#placeList?.body === body)
|
|
366
|
+
this.#markPlaces();
|
|
367
|
+
}, () => {
|
|
368
|
+
this.#placeLoading = undefined;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
this.#placeLayer?.clear();
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (this.#placeLayer === undefined && this.shadowRoot !== null) {
|
|
375
|
+
this.#placeLayer = createPlaceLayer(this.shadowRoot, {
|
|
376
|
+
lang: () => (this.getAttribute("lang") === "ja" ? "ja" : "en"),
|
|
377
|
+
pick: (place, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body, place, x: at.x, y: at.y }, bubbles: true, composed: true })),
|
|
378
|
+
});
|
|
379
|
+
// a picture with buttons in it is a group, not an image
|
|
380
|
+
if (this.getAttribute("role") === "img")
|
|
381
|
+
this.setAttribute("role", "group");
|
|
382
|
+
}
|
|
383
|
+
const w = this.#stage.clientWidth;
|
|
384
|
+
const h = this.#stage.clientHeight;
|
|
385
|
+
if (this.#placeLayer === undefined || w <= 0 || h <= 0)
|
|
386
|
+
return;
|
|
387
|
+
const aspect = w / h;
|
|
388
|
+
const half = state.extent / Math.max(0.05, state.zoom);
|
|
389
|
+
const halfW = aspect >= 1 ? half * aspect : half;
|
|
390
|
+
const halfH = aspect >= 1 ? half : half / aspect;
|
|
391
|
+
const left = state.panX * half - halfW;
|
|
392
|
+
const top = state.panY * half + halfH;
|
|
393
|
+
const facts = this.#facts();
|
|
394
|
+
const ax = facts.axesKm;
|
|
395
|
+
const scale = ax ? [ax[1] / facts.radiusKm, ax[2] / facts.radiusKm, ax[0] / facts.radiusKm] : [1, 1 - facts.flattening, 1];
|
|
396
|
+
const marks = placeMarks(this.#placeList.list, layers, {
|
|
397
|
+
centre: [0, 0, 0],
|
|
398
|
+
radius: 1,
|
|
399
|
+
pole: state.pose.pole,
|
|
400
|
+
meridian: state.pose.meridian,
|
|
401
|
+
scale,
|
|
402
|
+
toward: [0, 0, 1],
|
|
403
|
+
project: (p) => ({ x: ((p[0] - left) / (2 * halfW)) * w, y: ((top - p[1]) / (2 * halfH)) * h }),
|
|
404
|
+
width: w,
|
|
405
|
+
height: h,
|
|
406
|
+
radiusPx: (Math.min(w, h) / 2) * (state.zoom / state.extent),
|
|
407
|
+
}, facts.radiusKm);
|
|
408
|
+
this.#placeLayer.set(marks);
|
|
409
|
+
}
|
|
260
410
|
/** What the element is doing now. */
|
|
261
411
|
get state() {
|
|
262
412
|
return this.#state;
|
|
@@ -302,6 +452,17 @@ export class WakuseiBody extends HTMLElement {
|
|
|
302
452
|
this.#applyHover();
|
|
303
453
|
for (const name of ["pointerdown", "wheel", "keydown"])
|
|
304
454
|
this.addEventListener(name, this.#measure, true);
|
|
455
|
+
if (typeof ResizeObserver === "function") {
|
|
456
|
+
this.#placeResize = new ResizeObserver(() => {
|
|
457
|
+
if (this.#placeLayer !== undefined)
|
|
458
|
+
this.#markPlaces();
|
|
459
|
+
});
|
|
460
|
+
this.#placeResize.observe(this.#stage);
|
|
461
|
+
}
|
|
462
|
+
this.#placeHeard = onPlacesLoader(() => {
|
|
463
|
+
this.#placeList = undefined;
|
|
464
|
+
this.#markPlaces();
|
|
465
|
+
});
|
|
305
466
|
this.#carry();
|
|
306
467
|
this.#queue();
|
|
307
468
|
}
|
|
@@ -320,6 +481,12 @@ export class WakuseiBody extends HTMLElement {
|
|
|
320
481
|
this.#hands = undefined;
|
|
321
482
|
this.#handsKey = "";
|
|
322
483
|
this.#disposeView(true);
|
|
484
|
+
this.#placeLayer?.dispose();
|
|
485
|
+
this.#placeLayer = undefined;
|
|
486
|
+
this.#placeResize?.disconnect();
|
|
487
|
+
this.#placeResize = undefined;
|
|
488
|
+
this.#placeHeard?.();
|
|
489
|
+
this.#placeHeard = undefined;
|
|
323
490
|
}
|
|
324
491
|
attributeChangedCallback(name) {
|
|
325
492
|
if (!this.isConnected)
|
|
@@ -343,6 +510,8 @@ export class WakuseiBody extends HTMLElement {
|
|
|
343
510
|
this.#refreshLimits();
|
|
344
511
|
}
|
|
345
512
|
this.#lastAnchors = -1;
|
|
513
|
+
if (name === "places" || name === "lang" || name === "body" || name === "look" || name === "star")
|
|
514
|
+
this.#markPlaces();
|
|
346
515
|
this.#queue();
|
|
347
516
|
}
|
|
348
517
|
/** Put the picture on the page's one WebGL context and draw it, moving if it is asked to. Resolves true when it is live. A `line` look has nothing to take and resolves false. */
|
|
@@ -685,6 +854,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
685
854
|
const delegate = this.look === "line" ? delegates.get(this.body) : undefined;
|
|
686
855
|
if (delegate !== undefined && (await this.#delegated(delegate)))
|
|
687
856
|
return;
|
|
857
|
+
const undelegated = this.#delegateEl !== undefined;
|
|
688
858
|
if (this.#delegateEl !== undefined) {
|
|
689
859
|
this.#delegateEl.remove();
|
|
690
860
|
this.#delegateEl = undefined;
|
|
@@ -697,6 +867,9 @@ export class WakuseiBody extends HTMLElement {
|
|
|
697
867
|
this.#drawLine();
|
|
698
868
|
if (this.look === "line")
|
|
699
869
|
this.#set("line");
|
|
870
|
+
// the tick stopped while the other package's globe was shown
|
|
871
|
+
if (undelegated)
|
|
872
|
+
this.#resume();
|
|
700
873
|
return;
|
|
701
874
|
}
|
|
702
875
|
const sig = `${this.#star()?.key ?? this.body}|${this.look}`;
|
|
@@ -835,6 +1008,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
835
1008
|
},
|
|
836
1009
|
});
|
|
837
1010
|
this.#view = this.#renderer.view(this.#stage, item);
|
|
1011
|
+
this.#markPlaces(state);
|
|
838
1012
|
this.#set("loading");
|
|
839
1013
|
if (this.#visible)
|
|
840
1014
|
this.#still();
|
|
@@ -898,6 +1072,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
898
1072
|
const state = this.#sceneOf(this.#frameNow());
|
|
899
1073
|
this.#sceneState = state;
|
|
900
1074
|
scene.apply(state);
|
|
1075
|
+
this.#markPlaces(state);
|
|
901
1076
|
this.#textureWidth = scene.textureWidth;
|
|
902
1077
|
this.#door.announce();
|
|
903
1078
|
}
|
|
@@ -919,7 +1094,8 @@ export class WakuseiBody extends HTMLElement {
|
|
|
919
1094
|
}
|
|
920
1095
|
#lineTick() {
|
|
921
1096
|
this.#stopTick();
|
|
922
|
-
|
|
1097
|
+
// a body another package draws (the Earth's globe) is that package's to turn: this package's line drawn here would replace it
|
|
1098
|
+
if (!this.#visible || document.visibilityState === "hidden" || !this.#moving || this.look !== "line" || this.#delegateEl !== undefined)
|
|
923
1099
|
return;
|
|
924
1100
|
this.#drawLine();
|
|
925
1101
|
this.#tick = setTimeout(() => this.#lineTick(), 1000 / 30);
|