@johnmorrisdotca/chikyu-earth 0.34.1 → 0.36.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 +20 -0
- package/NOTICE.md +23 -1
- package/README.md +20 -2
- package/dist/borders/layer.d.ts +75 -0
- package/dist/borders/layer.js +136 -0
- package/dist/borders/lines.d.ts +138 -0
- package/dist/borders/lines.js +227 -0
- package/dist/cities/host.d.ts +9 -0
- package/dist/cities/host.js +14 -2
- package/dist/country-names/geometry.d.ts +264 -0
- package/dist/country-names/geometry.js +372 -0
- package/dist/country-names/host.d.ts +82 -0
- package/dist/country-names/host.js +212 -0
- package/dist/grid/layer.d.ts +45 -0
- package/dist/grid/layer.js +66 -0
- package/dist/grid/lines.d.ts +85 -0
- package/dist/grid/lines.js +113 -0
- package/dist/markers/go-to-place.d.ts +27 -0
- package/dist/markers/go-to-place.js +35 -0
- package/dist/markers/index.d.ts +2 -1
- package/dist/markers/index.js +2 -1
- package/dist/markers/layer.d.ts +7 -0
- package/dist/markers/layer.js +7 -0
- package/dist/markers/place-layer.d.ts +58 -7
- package/dist/markers/place-layer.js +326 -64
- package/dist/markers/place-sprites.d.ts +33 -0
- package/dist/markers/place-sprites.js +161 -0
- package/dist/markers/places.d.ts +91 -6
- package/dist/markers/places.js +135 -6
- package/dist/realistic/earth.d.ts +11 -0
- package/dist/realistic/earth.js +54 -0
- package/dist/realistic/element.d.ts +84 -4
- package/dist/realistic/element.js +224 -27
- package/dist/realistic/immersive.d.ts +7 -0
- package/dist/realistic/immersive.js +17 -0
- package/dist/realistic/index.d.ts +7 -0
- package/dist/realistic/index.js +3 -0
- package/dist/realistic/textures.d.ts +3 -0
- package/dist/sky/culture-lines.d.ts +56 -0
- package/dist/sky/culture-lines.js +82 -0
- package/dist/sky/figure-pick.d.ts +75 -0
- package/dist/sky/figure-pick.js +200 -0
- package/dist/sky/host.d.ts +17 -1
- package/dist/sky/host.js +615 -71
- package/dist/sky/keep-clear.d.ts +63 -0
- package/dist/sky/keep-clear.js +55 -0
- package/dist/space/element.d.ts +105 -10
- package/dist/space/element.js +275 -18
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +1 -1
- package/dist/space/satellite-model.d.ts +22 -0
- package/dist/space/satellite-model.js +38 -0
- package/dist/space/scene.d.ts +56 -7
- package/dist/space/scene.js +124 -23
- package/package.json +3 -3
|
@@ -5,9 +5,14 @@ import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/type
|
|
|
5
5
|
import { type SatelliteStyle } from "../space/satellite-layer.ts";
|
|
6
6
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
7
7
|
import { type BodyLabelSettings } from "./body-label.ts";
|
|
8
|
+
import type { SkyKeepClear } from "../sky/keep-clear.ts";
|
|
8
9
|
import type { SkyLabelStyle } from "../sky/style.ts";
|
|
9
10
|
import { type Place, type PlaceLook } from "../markers/places.ts";
|
|
10
11
|
import { type CityNamesStyle } from "../cities/host.ts";
|
|
12
|
+
import { type BorderSets } from "../borders/lines.ts";
|
|
13
|
+
import type { BorderData, BorderStats } from "../borders/layer.ts";
|
|
14
|
+
import type { GridStats } from "../grid/layer.ts";
|
|
15
|
+
import { type CountryNamesStats, type CountryNamesStyle } from "../country-names/host.ts";
|
|
11
16
|
import { setSharedRenderer, setThreeLoader } from "./shared.ts";
|
|
12
17
|
export { setSharedRenderer, setThreeLoader };
|
|
13
18
|
export type { CameraMode };
|
|
@@ -86,6 +91,13 @@ export declare const readTime: (value: string | null) => number | "now";
|
|
|
86
91
|
* is sent when the strongest active shower changes, with `detail: { shower, zhr }` (`shower` is `null` when none is active).
|
|
87
92
|
* `meteors-strength` (0 to 1, the property `meteorsStrength`; 1 when the page says nothing) makes them subtler: fewer streaks and fainter ones, none at 0, and nothing that is real changes.
|
|
88
93
|
*
|
|
94
|
+
* `borders` draws the borders on the land as thin lines that turn with the Earth: `countries` (chizu's, at any size), `regions` (provinces, states and the like, from the page's `borderData.regions`,
|
|
95
|
+
* once the Earth is large enough to tell them apart), or both with a bare attribute. The shapes are loaded only when a set is switched on; `chikyu-borders-unavailable` is sent when they cannot be.
|
|
96
|
+
*
|
|
97
|
+
* `grid` draws the meridians and parallels on the Earth (every 30 degrees while it is small on the screen, every 15 once it is large), with the equator, the tropics, the polar circles and the prime
|
|
98
|
+
* meridian picked out, light on the day side and dim on the night side. `country-names` names the countries at the middle of the part of each in view, in the page's language, never over another
|
|
99
|
+
* name, as many as fit (40 at most, or the number given); the outlines are loaded only when it is set, and `chikyu-country-names-unavailable` is sent when they cannot be.
|
|
100
|
+
*
|
|
89
101
|
* @example
|
|
90
102
|
* ```ts no-run
|
|
91
103
|
* import type { ChikyuEarthRealistic } from "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
@@ -144,13 +156,46 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
144
156
|
get skyStyle(): Partial<SkyLabelStyle>;
|
|
145
157
|
set skyStyle(value: Partial<SkyLabelStyle>);
|
|
146
158
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
|
|
159
|
+
* The constellation that is picked, by its IAU abbreviation (`Ori`), or `null`. A reader picks one by a click or a tap on its lines or inside its figure (and with the key `C`, or `Shift`+`C` for the previous, while the element has the focus); a click on empty sky, or `Escape`, lets it go. The picked figure's lines are lit and its name is
|
|
160
|
+
* shown at the middle of the part of it in view, until another is picked or it is let go. A page sets the property to pick one itself, which sends no event. `chikyu-constellation-pick` is sent at each pick of the reader's, with `detail` `{ abbreviation, id, name, english, japanese, kind, culture }` (`culture` is `iau` unless `constellation-culture` names another), and `null` when it is let go; `chikyu-constellation-hover` is sent the same way as a mouse rests on a figure and leaves it.
|
|
161
|
+
* Needs `constellation-lines` set. `constellation-culture` (`iau` by default, `western`, `japanese` or `chinese`; each is fetched only when asked for, and the value is exactly what the page sets) makes the figures, the pick and the names those of that sky culture. The attribute `constellation-names` (off by default) writes the name of every figure in view at the middle of the part of it that is on the picture, quieter than the star names and clear of them, of the Earth, the Moon, the Sun, the places and satellites named, and of the places kept clear (`keepClear`).
|
|
162
|
+
*/
|
|
163
|
+
get constellation(): string | null;
|
|
164
|
+
set constellation(value: string | null);
|
|
165
|
+
/**
|
|
166
|
+
* Places on the picture where the sky's names must not go: a page's own text laid over the element, say. Each is a rectangle in the element's own CSS pixels from its top left (`{ x, y, width, height }`), or an element of the page whose box is read. A star name whose box touches
|
|
167
|
+
* one is left out, and so is a star whose point is in one (the next star is named instead); the picked constellation's name is moved clear of it. The lines are still drawn. The boxes are read when the list changes, when the page or an element is resized or scrolled, and not at each frame: a
|
|
168
|
+
* page that moves its text without resizing it sets the property again. The attribute `keep-clear` takes a CSS selector for the same (`keep-clear=".hero h1, .hero .lead"`). Nothing is redrawn at rest.
|
|
169
|
+
*/
|
|
170
|
+
get keepClear(): SkyKeepClear[];
|
|
171
|
+
set keepClear(value: readonly SkyKeepClear[] | null);
|
|
172
|
+
/**
|
|
173
|
+
* Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind, color }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
|
|
174
|
+
* (the default: quieter), and `color` an optional CSS colour of its own. The first `PLACE_MARKS` in sight (`here` first, then in the order given) stand up out of the ground with their names; every other place
|
|
175
|
+
* is a ring on the ground, all of them one draw call, and places that crowd are gathered into one ring with their count. They turn with the Earth, are hidden on its far side, are dimmer on its night side
|
|
176
|
+
* and keep their size in pixels at any zoom. Names never overlap one another; one with no room is left out. The element stores nothing and sends nothing: the page hands the places over and keeps them where
|
|
177
|
+
* it likes. Setting the property writes the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight and for a reader who asked
|
|
178
|
+
* for less motion.
|
|
151
179
|
*/
|
|
152
180
|
get places(): Place[];
|
|
153
181
|
set places(value: readonly Place[]);
|
|
182
|
+
/**
|
|
183
|
+
* Turn the Earth so a place of `places` is in the middle, at a pace a reader can follow (at once with `smooth: false`, for a reader who asked for less motion, or before the picture is live); the zoom
|
|
184
|
+
* and pan stay. The place is named by its `id`, or by its label in any case. The tilt is held to 90 degrees either way, so a place more than 90 degrees of latitude from `center` comes as near the middle
|
|
185
|
+
* as that allows.
|
|
186
|
+
*
|
|
187
|
+
* @param text - The place's id or label.
|
|
188
|
+
* @param options - `smooth` (true by default).
|
|
189
|
+
* @returns The place, once the turn has started; `undefined` when there is no such place.
|
|
190
|
+
*/
|
|
191
|
+
goToPlace(text: string, options?: {
|
|
192
|
+
smooth?: boolean;
|
|
193
|
+
}): Promise<Place | undefined>;
|
|
194
|
+
/**
|
|
195
|
+
* Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
|
|
196
|
+
*/
|
|
197
|
+
get placeGroups(): boolean;
|
|
198
|
+
set placeGroups(value: boolean);
|
|
154
199
|
/** How the places are drawn (the attribute `places-look`): `beam` (a light rising out of the ground with a ring at its foot, the default), `pin` (a thin stick with a round head) or `ring` (only the ring on the ground). */
|
|
155
200
|
get placesLook(): PlaceLook;
|
|
156
201
|
set placesLook(value: PlaceLook);
|
|
@@ -159,6 +204,27 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
159
204
|
*/
|
|
160
205
|
get cityNamesStyle(): CityNamesStyle;
|
|
161
206
|
set cityNamesStyle(value: CityNamesStyle);
|
|
207
|
+
/** Whether the meridians and parallels are drawn (the attribute `grid`). Setting it writes the attribute, or takes it away. */
|
|
208
|
+
get grid(): boolean;
|
|
209
|
+
set grid(value: boolean);
|
|
210
|
+
/**
|
|
211
|
+
* The look of the names of countries (`country-names`): font, weight, colour, the outline round the text, and the smallest and largest text size. Any of them may be left out; the Earth's size, the
|
|
212
|
+
* language and the data are not set here.
|
|
213
|
+
*/
|
|
214
|
+
get countryNamesStyle(): CountryNamesStyle;
|
|
215
|
+
set countryNamesStyle(value: CountryNamesStyle);
|
|
216
|
+
/**
|
|
217
|
+
* Which borders are drawn (the attribute `borders`): the countries' at any size, and the regions' (provinces, states, prefectures) once the Earth is large enough on the screen to tell them apart.
|
|
218
|
+
* Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
|
|
219
|
+
*/
|
|
220
|
+
get borders(): BorderSets;
|
|
221
|
+
set borders(value: BorderSets);
|
|
222
|
+
/**
|
|
223
|
+
* Where the borders' shapes come from (see `BorderData`): `countries` in place of chizu's `world-geo`, and `regions`, a country's regions by its code, which draws the regions; without it none are drawn.
|
|
224
|
+
* Set it before `borders` is switched on: shapes already loaded are kept.
|
|
225
|
+
*/
|
|
226
|
+
get borderData(): BorderData;
|
|
227
|
+
set borderData(value: BorderData);
|
|
162
228
|
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
163
229
|
get controller(): ViewController | undefined;
|
|
164
230
|
/**
|
|
@@ -253,6 +319,10 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
253
319
|
names: number;
|
|
254
320
|
figures: number;
|
|
255
321
|
picked: string | null;
|
|
322
|
+
pick: string | null;
|
|
323
|
+
hover: string | null;
|
|
324
|
+
constellations: number;
|
|
325
|
+
culture: string;
|
|
256
326
|
renders: number;
|
|
257
327
|
lang: string;
|
|
258
328
|
stars: {
|
|
@@ -267,6 +337,10 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
267
337
|
shown: number;
|
|
268
338
|
labels: number;
|
|
269
339
|
renders: number;
|
|
340
|
+
marks: number;
|
|
341
|
+
groups: number;
|
|
342
|
+
sprites: number;
|
|
343
|
+
omitted: number;
|
|
270
344
|
};
|
|
271
345
|
/** The names of cities: whether `city-names` is set and the most it asks for, the Earth's radius on the screen, the tiers of kuni's cities that have arrived and how many cities, the names shown at the last draw and how many times the layer was drawn. */
|
|
272
346
|
cityNames: {
|
|
@@ -278,6 +352,12 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
278
352
|
names: number;
|
|
279
353
|
renders: number;
|
|
280
354
|
};
|
|
355
|
+
/** The borders: the segments of each set, whether each was drawn at the last draw, the countries whose regions have arrived, how many times a set's lines were made, and whether a set could not be loaded. */
|
|
356
|
+
borders: BorderStats;
|
|
357
|
+
/** The grid: whether it was drawn at the last draw, whether every 15 degrees (else 30), its segments then, how many times its lines were made, and whether it could not be made. */
|
|
358
|
+
grid: GridStats;
|
|
359
|
+
/** The names of countries: whether `country-names` is set and the most it asks for, the countries loaded, the names shown at the last draw, how many times they were laid out, and whether the outlines could not be loaded. */
|
|
360
|
+
countryNames: CountryNamesStats;
|
|
281
361
|
};
|
|
282
362
|
/**
|
|
283
363
|
* Apply a shared view controller's camera (yaw, tilt, zoom, pan). A change under half a pixel is not drawn, a settled change always is,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
5
5
|
import { adoptStyles } from "../adopt.js";
|
|
6
6
|
import { airFor, readAirThickness } from "./air.js";
|
|
7
|
+
import { IMMERSIVE_STYLE, immersiveWheel } from "./immersive.js";
|
|
7
8
|
import { NOTES_STYLE, setAirNote } from "./air-note.js";
|
|
8
9
|
import { cameraCentre, createEarthItem, discRadius, lookAt, newModel } from "./earth.js";
|
|
9
10
|
import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
|
|
@@ -15,15 +16,21 @@ import { folderSource } from "../door/map.js";
|
|
|
15
16
|
import { ownCredit } from "../door/own.js";
|
|
16
17
|
import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "./body-label.js";
|
|
17
18
|
import { createSkyHost, SKY_ATTRIBUTES, SKY_STYLE } from "../sky/host.js";
|
|
18
|
-
import { cleanPlaces, orthoView, readPlaces } from "../markers/places.js";
|
|
19
|
+
import { cleanPlaces, orthoView, readPlaceGroups, readPlaces } from "../markers/places.js";
|
|
19
20
|
import { createPlaceLayer, PLACE_STYLE, readPlaceLook } from "../markers/place-layer.js";
|
|
21
|
+
import { aimAt, findPlace, glideView } from "../markers/go-to-place.js";
|
|
22
|
+
import { subsolarPoint } from "./sun.js";
|
|
20
23
|
import { CITY_NAMES_ATTRIBUTES, CITY_NAMES_STYLE, createCityHost } from "../cities/host.js";
|
|
21
24
|
import { project } from "../markers/project.js";
|
|
25
|
+
import { BORDER_ATTRIBUTES, readBorders } from "../borders/lines.js";
|
|
26
|
+
import { GRID_ATTRIBUTES, readGrid } from "../grid/lines.js";
|
|
27
|
+
import { COUNTRY_NAMES_ATTRIBUTES } from "../country-names/geometry.js";
|
|
28
|
+
import { COUNTRY_NAMES_STYLE, createCountryHost } from "../country-names/host.js";
|
|
22
29
|
import { createGate, frameCap } from "./gate.js";
|
|
23
30
|
import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
|
|
24
31
|
export { setSharedRenderer, setThreeLoader };
|
|
25
32
|
import { MAX_TEXTURE, TIERS } from "./tiers.js";
|
|
26
|
-
const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative;isolation:isolate}
|
|
33
|
+
const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative;isolation:isolate}" + IMMERSIVE_STYLE + "#stage,#overlay{position:absolute;inset:0}#overlay{pointer-events:none}" + PLACE_STYLE + SKY_STYLE + COUNTRY_NAMES_STYLE + CITY_NAMES_STYLE + METEOR_NOTE_STYLE + NOTES_STYLE;
|
|
27
34
|
const RAD = Math.PI / 180;
|
|
28
35
|
/** The Sun and the clouds are re-placed this often at real time: 15 degrees an hour is 0.25 degree a minute. */
|
|
29
36
|
const LIVE_TICK_MS = 60_000;
|
|
@@ -48,8 +55,6 @@ const readCentre = (value) => {
|
|
|
48
55
|
const readCamera = (value) => (value === "ground" || value === "sun" ? value : "space");
|
|
49
56
|
/** A `cloud-drift` attribute: degrees an hour the clouds are made to move eastward against the ground (0, the default: where the picture has them). */
|
|
50
57
|
const readDrift = (value) => (value !== null && Number.isFinite(Number(value)) ? Number(value) : 0);
|
|
51
|
-
/** The plain wheel in an immersive view is a pinch of this share: a notch (100) zooms about 1.2 times, as the family's mouse wheel does with Alt. */
|
|
52
|
-
const WHEEL_AS_PINCH = 0.2;
|
|
53
58
|
/** The quickest a satellite goes round, degrees a second (a low orbit: 88 minutes). */
|
|
54
59
|
const SATELLITE_RATE = 360 / (88 * 60);
|
|
55
60
|
const SATELLITE_COLORS = ["#ffd54f", "#7fd4ff", "#ff8fa3", "#9ef0a8"];
|
|
@@ -116,6 +121,13 @@ export const readTime = (value) => {
|
|
|
116
121
|
* is sent when the strongest active shower changes, with `detail: { shower, zhr }` (`shower` is `null` when none is active).
|
|
117
122
|
* `meteors-strength` (0 to 1, the property `meteorsStrength`; 1 when the page says nothing) makes them subtler: fewer streaks and fainter ones, none at 0, and nothing that is real changes.
|
|
118
123
|
*
|
|
124
|
+
* `borders` draws the borders on the land as thin lines that turn with the Earth: `countries` (chizu's, at any size), `regions` (provinces, states and the like, from the page's `borderData.regions`,
|
|
125
|
+
* once the Earth is large enough to tell them apart), or both with a bare attribute. The shapes are loaded only when a set is switched on; `chikyu-borders-unavailable` is sent when they cannot be.
|
|
126
|
+
*
|
|
127
|
+
* `grid` draws the meridians and parallels on the Earth (every 30 degrees while it is small on the screen, every 15 once it is large), with the equator, the tropics, the polar circles and the prime
|
|
128
|
+
* meridian picked out, light on the day side and dim on the night side. `country-names` names the countries at the middle of the part of each in view, in the page's language, never over another
|
|
129
|
+
* name, as many as fit (40 at most, or the number given); the outlines are loaded only when it is set, and `chikyu-country-names-unavailable` is sent when they cannot be.
|
|
130
|
+
*
|
|
119
131
|
* @example
|
|
120
132
|
* ```ts no-run
|
|
121
133
|
* import type { ChikyuEarthRealistic } from "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
@@ -134,7 +146,7 @@ export const readTime = (value) => {
|
|
|
134
146
|
* ```
|
|
135
147
|
*/
|
|
136
148
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
137
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look"];
|
|
149
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups"];
|
|
138
150
|
#model = newModel();
|
|
139
151
|
#mode = "now";
|
|
140
152
|
#view;
|
|
@@ -161,9 +173,14 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
161
173
|
/** The names of cities on the Earth (`city-names`), and the look of the names. */
|
|
162
174
|
#cities;
|
|
163
175
|
#citiesStyle = {};
|
|
176
|
+
/** The names of the countries on the Earth (`country-names`), and the look of the names. */
|
|
177
|
+
#countries;
|
|
178
|
+
#countriesStyle = {};
|
|
164
179
|
#listeners = new Set();
|
|
165
180
|
#placeLayer;
|
|
166
181
|
#placeList = [];
|
|
182
|
+
/** Counts the turns to a place, so a new one stops the one before. */
|
|
183
|
+
#placeGlide = 0;
|
|
167
184
|
#hands;
|
|
168
185
|
#reach = null;
|
|
169
186
|
/** The page has set a `speed` since the element came into the page: for a reader who prefers reduced motion, that is the Play that lets meteors start. */
|
|
@@ -172,6 +189,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
172
189
|
/** The names of the stars and the constellation lines (`star-names`, `constellation-lines`), and the look of the names. */
|
|
173
190
|
#sky;
|
|
174
191
|
#skyStyle = {};
|
|
192
|
+
#keepClear = [];
|
|
175
193
|
#airNote;
|
|
176
194
|
#onContext = (state) => {
|
|
177
195
|
if (state === "unavailable")
|
|
@@ -214,17 +232,31 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
214
232
|
loadFont: loadMichroma,
|
|
215
233
|
});
|
|
216
234
|
this.#sky.setStyle(this.#skyStyle);
|
|
235
|
+
this.#sky.setKeepClear(this.#keepClear);
|
|
217
236
|
this.#placeLayer = createPlaceLayer(root.getElementById("places"));
|
|
218
237
|
this.#placeList = readPlaces(this.getAttribute("places"));
|
|
219
238
|
this.#placeLayer.set(this.#placeList);
|
|
220
239
|
this.#placeLayer.look = readPlaceLook(this.getAttribute("places-look"));
|
|
240
|
+
this.#placeLayer.grouping = readPlaceGroups(this.getAttribute("place-groups"));
|
|
221
241
|
this.#cities = createCityHost({
|
|
222
242
|
root,
|
|
223
243
|
attribute: (name) => this.getAttribute(name),
|
|
224
244
|
language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
|
|
225
245
|
onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-city-names-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
246
|
+
onLayout: () => this.#countryFrame(),
|
|
226
247
|
});
|
|
227
248
|
this.#cities.setStyle(this.#citiesStyle);
|
|
249
|
+
Object.assign(this.#model.borders, readBorders(this.getAttribute("borders")));
|
|
250
|
+
this.#model.borders.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-borders-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
|
|
251
|
+
this.#model.grid.on = readGrid(this.getAttribute("grid"));
|
|
252
|
+
this.#model.grid.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-grid-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
|
|
253
|
+
this.#countries = createCountryHost({
|
|
254
|
+
root,
|
|
255
|
+
attribute: (name) => this.getAttribute(name),
|
|
256
|
+
language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
|
|
257
|
+
onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-country-names-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
258
|
+
});
|
|
259
|
+
this.#countries.setStyle(this.#countriesStyle);
|
|
228
260
|
this.#played = false;
|
|
229
261
|
this.#model.meteors.on = this.#meteorsAsked();
|
|
230
262
|
this.#model.meteors.strength = readMeteorStrength(this.getAttribute("meteors-strength"));
|
|
@@ -266,16 +298,24 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
266
298
|
onTiled: () => this.#door.announce(),
|
|
267
299
|
onSky: (sky) => this.#sky?.frame(sky),
|
|
268
300
|
onLabelError: (error) => this.dispatchEvent(new CustomEvent("chikyu-body-label-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
301
|
+
placeSprites: () => this.#placeLayer?.sprites ?? null,
|
|
269
302
|
onPose: (pose) => {
|
|
270
303
|
if (this.#hands)
|
|
271
304
|
this.#hands.controller.grabRadius = discRadius(pose.width, pose.height, 1);
|
|
272
305
|
this.#pose = { ...pose, transform: "" };
|
|
273
|
-
|
|
274
|
-
|
|
306
|
+
this.#posing = true;
|
|
307
|
+
try {
|
|
308
|
+
for (const listener of this.#listeners)
|
|
309
|
+
listener(this.#pose);
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
this.#posing = false;
|
|
313
|
+
}
|
|
275
314
|
if (this.#placeLayer && (this.#placeList.length > 0 || this.#placeLayer.stats.shown > 0))
|
|
276
|
-
this.#placeLayer.frame(orthoView(pose));
|
|
315
|
+
this.#placeLayer.frame(orthoView(pose), [], [], this.#model.light === "lit" ? null : subsolarPoint(this.#model.time));
|
|
277
316
|
this.#cityFrame();
|
|
278
317
|
},
|
|
318
|
+
onPlaceRings: (drawn) => this.#ringsDrawn(drawn),
|
|
279
319
|
onSatellitesError: (error) => this.dispatchEvent(new CustomEvent("chikyu-satellites-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
280
320
|
onError: (error) => this.#fail(error instanceof Error ? error.message : String(error)),
|
|
281
321
|
onTier: (layer, width) => {
|
|
@@ -329,6 +369,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
329
369
|
this.#placeLayer = undefined;
|
|
330
370
|
this.#cities?.dispose();
|
|
331
371
|
this.#cities = undefined;
|
|
372
|
+
this.#countries?.dispose();
|
|
373
|
+
this.#countries = undefined;
|
|
332
374
|
}
|
|
333
375
|
attributeChangedCallback(name, _old, value) {
|
|
334
376
|
if (name === "center")
|
|
@@ -371,6 +413,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
371
413
|
this.#applyBodyLabel();
|
|
372
414
|
this.#sky?.refresh();
|
|
373
415
|
this.#cities?.refresh();
|
|
416
|
+
this.#countries?.refresh();
|
|
374
417
|
}
|
|
375
418
|
}
|
|
376
419
|
else if (BODY_LABEL_ATTRIBUTES.includes(name))
|
|
@@ -386,8 +429,22 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
386
429
|
this.#placeLayer.look = readPlaceLook(value);
|
|
387
430
|
this.#gate?.soon();
|
|
388
431
|
}
|
|
432
|
+
else if (name === "place-groups" && this.#placeLayer) {
|
|
433
|
+
this.#placeLayer.grouping = readPlaceGroups(value);
|
|
434
|
+
this.#gate?.soon();
|
|
435
|
+
}
|
|
389
436
|
else if (CITY_NAMES_ATTRIBUTES.includes(name))
|
|
390
437
|
this.#cities?.refresh();
|
|
438
|
+
else if (name === "borders") {
|
|
439
|
+
Object.assign(this.#model.borders, readBorders(value));
|
|
440
|
+
this.#gate?.soon();
|
|
441
|
+
}
|
|
442
|
+
else if (name === "grid") {
|
|
443
|
+
this.#model.grid.on = readGrid(value);
|
|
444
|
+
this.#gate?.soon();
|
|
445
|
+
}
|
|
446
|
+
else if (COUNTRY_NAMES_ATTRIBUTES.includes(name))
|
|
447
|
+
this.#countries?.refresh();
|
|
391
448
|
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
392
449
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
393
450
|
}
|
|
@@ -479,10 +536,35 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
479
536
|
this.#sky?.setStyle(this.#skyStyle);
|
|
480
537
|
}
|
|
481
538
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
|
|
539
|
+
* The constellation that is picked, by its IAU abbreviation (`Ori`), or `null`. A reader picks one by a click or a tap on its lines or inside its figure (and with the key `C`, or `Shift`+`C` for the previous, while the element has the focus); a click on empty sky, or `Escape`, lets it go. The picked figure's lines are lit and its name is
|
|
540
|
+
* shown at the middle of the part of it in view, until another is picked or it is let go. A page sets the property to pick one itself, which sends no event. `chikyu-constellation-pick` is sent at each pick of the reader's, with `detail` `{ abbreviation, id, name, english, japanese, kind, culture }` (`culture` is `iau` unless `constellation-culture` names another), and `null` when it is let go; `chikyu-constellation-hover` is sent the same way as a mouse rests on a figure and leaves it.
|
|
541
|
+
* Needs `constellation-lines` set. `constellation-culture` (`iau` by default, `western`, `japanese` or `chinese`; each is fetched only when asked for, and the value is exactly what the page sets) makes the figures, the pick and the names those of that sky culture. The attribute `constellation-names` (off by default) writes the name of every figure in view at the middle of the part of it that is on the picture, quieter than the star names and clear of them, of the Earth, the Moon, the Sun, the places and satellites named, and of the places kept clear (`keepClear`).
|
|
542
|
+
*/
|
|
543
|
+
get constellation() {
|
|
544
|
+
return this.#sky?.picked ?? null;
|
|
545
|
+
}
|
|
546
|
+
set constellation(value) {
|
|
547
|
+
this.#sky?.pick(value);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Places on the picture where the sky's names must not go: a page's own text laid over the element, say. Each is a rectangle in the element's own CSS pixels from its top left (`{ x, y, width, height }`), or an element of the page whose box is read. A star name whose box touches
|
|
551
|
+
* one is left out, and so is a star whose point is in one (the next star is named instead); the picked constellation's name is moved clear of it. The lines are still drawn. The boxes are read when the list changes, when the page or an element is resized or scrolled, and not at each frame: a
|
|
552
|
+
* page that moves its text without resizing it sets the property again. The attribute `keep-clear` takes a CSS selector for the same (`keep-clear=".hero h1, .hero .lead"`). Nothing is redrawn at rest.
|
|
553
|
+
*/
|
|
554
|
+
get keepClear() {
|
|
555
|
+
return [...this.#keepClear];
|
|
556
|
+
}
|
|
557
|
+
set keepClear(value) {
|
|
558
|
+
this.#keepClear = value ? [...value] : [];
|
|
559
|
+
this.#sky?.setKeepClear(this.#keepClear);
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind, color }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
|
|
563
|
+
* (the default: quieter), and `color` an optional CSS colour of its own. The first `PLACE_MARKS` in sight (`here` first, then in the order given) stand up out of the ground with their names; every other place
|
|
564
|
+
* is a ring on the ground, all of them one draw call, and places that crowd are gathered into one ring with their count. They turn with the Earth, are hidden on its far side, are dimmer on its night side
|
|
565
|
+
* and keep their size in pixels at any zoom. Names never overlap one another; one with no room is left out. The element stores nothing and sends nothing: the page hands the places over and keeps them where
|
|
566
|
+
* it likes. Setting the property writes the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight and for a reader who asked
|
|
567
|
+
* for less motion.
|
|
486
568
|
*/
|
|
487
569
|
get places() {
|
|
488
570
|
return this.#placeList.map((place) => ({ ...place }));
|
|
@@ -494,6 +576,55 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
494
576
|
else
|
|
495
577
|
this.setAttribute("places", JSON.stringify(clean));
|
|
496
578
|
}
|
|
579
|
+
/**
|
|
580
|
+
* Turn the Earth so a place of `places` is in the middle, at a pace a reader can follow (at once with `smooth: false`, for a reader who asked for less motion, or before the picture is live); the zoom
|
|
581
|
+
* and pan stay. The place is named by its `id`, or by its label in any case. The tilt is held to 90 degrees either way, so a place more than 90 degrees of latitude from `center` comes as near the middle
|
|
582
|
+
* as that allows.
|
|
583
|
+
*
|
|
584
|
+
* @param text - The place's id or label.
|
|
585
|
+
* @param options - `smooth` (true by default).
|
|
586
|
+
* @returns The place, once the turn has started; `undefined` when there is no such place.
|
|
587
|
+
*/
|
|
588
|
+
async goToPlace(text, options = {}) {
|
|
589
|
+
const place = findPlace(this.#placeList, text);
|
|
590
|
+
if (!place)
|
|
591
|
+
return undefined;
|
|
592
|
+
const view = this.#model.view;
|
|
593
|
+
const from = { yaw: view.yaw, tilt: view.tilt };
|
|
594
|
+
const to = aimAt(cameraCentre(this.#model), place, from);
|
|
595
|
+
const bar = this.hasAttribute("data-kazoku-bar") && this.id ? this.getRootNode().querySelector?.(`kazoku-view-controls[for="${CSS.escape(this.id)}"]`) : null;
|
|
596
|
+
const controls = (bar ? Reflect.get(bar, "controller") : undefined) ?? this.#hands?.controller;
|
|
597
|
+
const glide = (this.#placeGlide += 1);
|
|
598
|
+
const set = (yaw, tilt, final) => {
|
|
599
|
+
if (controls)
|
|
600
|
+
controls.set({ yaw, tilt }, final, "place");
|
|
601
|
+
else
|
|
602
|
+
this.setView({ ...this.#model.view, yaw, tilt }, final);
|
|
603
|
+
};
|
|
604
|
+
glideView(set, from, to, options.smooth !== false && !prefersLessMotion() && this.#view?.live === true, () => glide === this.#placeGlide && this.isConnected);
|
|
605
|
+
return { ...place };
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
|
|
609
|
+
*/
|
|
610
|
+
get placeGroups() {
|
|
611
|
+
return this.#placeLayer?.grouping ?? readPlaceGroups(this.getAttribute("place-groups"));
|
|
612
|
+
}
|
|
613
|
+
set placeGroups(value) {
|
|
614
|
+
if (value)
|
|
615
|
+
this.removeAttribute("place-groups");
|
|
616
|
+
else
|
|
617
|
+
this.setAttribute("place-groups", "off");
|
|
618
|
+
}
|
|
619
|
+
/** The picture said whether it can draw the rings of the places that are not markers of their own. Without `Points` the places' layer draws them itself and the page is told once, so no place is lost without a word. */
|
|
620
|
+
#ringsDrawn(drawn) {
|
|
621
|
+
if (!this.#placeLayer || this.#placeLayer.ringsInPicture === drawn)
|
|
622
|
+
return;
|
|
623
|
+
this.#placeLayer.ringsInPicture = drawn;
|
|
624
|
+
if (!drawn)
|
|
625
|
+
this.dispatchEvent(new CustomEvent("chikyu-places-unavailable", { detail: { reason: "the three.js parts handed over lack Points: the places' rings are drawn as small circles in the page, at most 600, and stats.places.omitted counts the rest" } }));
|
|
626
|
+
this.#gate?.soon();
|
|
627
|
+
}
|
|
497
628
|
/** How the places are drawn (the attribute `places-look`): `beam` (a light rising out of the ground with a ring at its foot, the default), `pin` (a thin stick with a round head) or `ring` (only the ring on the ground). */
|
|
498
629
|
get placesLook() {
|
|
499
630
|
return this.#placeLayer?.look ?? readPlaceLook(this.getAttribute("places-look"));
|
|
@@ -511,22 +642,81 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
511
642
|
this.#citiesStyle = { ...value };
|
|
512
643
|
this.#cities?.setStyle(this.#citiesStyle);
|
|
513
644
|
}
|
|
514
|
-
/**
|
|
645
|
+
/** Whether the meridians and parallels are drawn (the attribute `grid`). Setting it writes the attribute, or takes it away. */
|
|
646
|
+
get grid() {
|
|
647
|
+
return readGrid(this.getAttribute("grid"));
|
|
648
|
+
}
|
|
649
|
+
set grid(value) {
|
|
650
|
+
if (value)
|
|
651
|
+
this.setAttribute("grid", "");
|
|
652
|
+
else
|
|
653
|
+
this.removeAttribute("grid");
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* The look of the names of countries (`country-names`): font, weight, colour, the outline round the text, and the smallest and largest text size. Any of them may be left out; the Earth's size, the
|
|
657
|
+
* language and the data are not set here.
|
|
658
|
+
*/
|
|
659
|
+
get countryNamesStyle() {
|
|
660
|
+
return { ...this.#countriesStyle };
|
|
661
|
+
}
|
|
662
|
+
set countryNamesStyle(value) {
|
|
663
|
+
this.#countriesStyle = { ...value };
|
|
664
|
+
this.#countries?.setStyle(this.#countriesStyle);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Which borders are drawn (the attribute `borders`): the countries' at any size, and the regions' (provinces, states, prefectures) once the Earth is large enough on the screen to tell them apart.
|
|
668
|
+
* Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
|
|
669
|
+
*/
|
|
670
|
+
get borders() {
|
|
671
|
+
return readBorders(this.getAttribute("borders"));
|
|
672
|
+
}
|
|
673
|
+
set borders(value) {
|
|
674
|
+
const words = [value.countries ? "countries" : "", value.regions ? "regions" : ""].filter(Boolean);
|
|
675
|
+
if (words.length === 0)
|
|
676
|
+
this.removeAttribute("borders");
|
|
677
|
+
else
|
|
678
|
+
this.setAttribute("borders", words.join(" "));
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Where the borders' shapes come from (see `BorderData`): `countries` in place of chizu's `world-geo`, and `regions`, a country's regions by its code, which draws the regions; without it none are drawn.
|
|
682
|
+
* Set it before `borders` is switched on: shapes already loaded are kept.
|
|
683
|
+
*/
|
|
684
|
+
get borderData() {
|
|
685
|
+
return { ...this.#model.borders.data };
|
|
686
|
+
}
|
|
687
|
+
set borderData(value) {
|
|
688
|
+
this.#model.borders.data = { ...value };
|
|
689
|
+
this.#gate?.soon();
|
|
690
|
+
}
|
|
691
|
+
/** Tells the names of cities, then of countries, where the Earth is in the picture just drawn (the orthographic view the markers share); the countries' names keep clear of the places' and the cities'. */
|
|
515
692
|
#cityFrame() {
|
|
516
693
|
const pose = this.#pose;
|
|
517
694
|
if (!this.#cities || !pose)
|
|
518
695
|
return;
|
|
519
|
-
|
|
696
|
+
const frame = {
|
|
520
697
|
width: pose.width,
|
|
521
698
|
height: pose.height,
|
|
522
699
|
radius: pose.radius,
|
|
700
|
+
disc: { x: pose.cx, y: pose.cy, radius: pose.radius },
|
|
523
701
|
project: (lon, lat, out) => {
|
|
524
702
|
const at = project(lon, lat, pose);
|
|
525
703
|
out.x = at.x;
|
|
526
704
|
out.y = at.y;
|
|
527
705
|
return at.z;
|
|
528
706
|
},
|
|
529
|
-
}
|
|
707
|
+
};
|
|
708
|
+
this.#cities.frame(frame);
|
|
709
|
+
this.#nameFrame = frame;
|
|
710
|
+
this.#countryFrame();
|
|
711
|
+
}
|
|
712
|
+
/** The frame the names were last laid out on. */
|
|
713
|
+
#nameFrame = null;
|
|
714
|
+
/** Lays the countries' names out on the last frame, clear of the places' and the cities' names as they are now. */
|
|
715
|
+
#countryFrame() {
|
|
716
|
+
const countries = this.#countries;
|
|
717
|
+
if (!countries || !this.#nameFrame)
|
|
718
|
+
return;
|
|
719
|
+
countries.frame(this.#nameFrame, countries.stats.on ? [...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...[...this.#claims.values()].flat()] : []);
|
|
530
720
|
}
|
|
531
721
|
/** Puts the name's settings and text right from the attributes (`body-label` and its family, `lang`). */
|
|
532
722
|
#applyBodyLabel() {
|
|
@@ -606,8 +796,21 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
606
796
|
this.#listeners.add(listener);
|
|
607
797
|
return () => this.#listeners.delete(listener);
|
|
608
798
|
},
|
|
799
|
+
claim: (owner, boxes) => {
|
|
800
|
+
if (boxes.length === 0)
|
|
801
|
+
this.#claims.delete(owner);
|
|
802
|
+
else
|
|
803
|
+
this.#claims.set(owner, boxes);
|
|
804
|
+
// laid out again only when the overlay changed between draws: at a draw the names are laid out after it anyway
|
|
805
|
+
if (!this.#posing)
|
|
806
|
+
this.#countryFrame();
|
|
807
|
+
},
|
|
609
808
|
};
|
|
610
809
|
}
|
|
810
|
+
/** The boxes overlays on the element (markers) take, by overlay. */
|
|
811
|
+
#claims = new Map();
|
|
812
|
+
/** True while the overlays are told of a draw. */
|
|
813
|
+
#posing = false;
|
|
611
814
|
/** Where the view starts: longitude and latitude; the shared controls' yaw and tilt turn it from there. */
|
|
612
815
|
get centre() {
|
|
613
816
|
return { ...this.#model.centre };
|
|
@@ -713,9 +916,12 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
713
916
|
assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
|
|
714
917
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
|
715
918
|
bodyLabel: { on: this.#model.bodyLabel.settings !== null, text: this.#model.bodyLabel.text, ...this.#model.bodyLabel.drawn },
|
|
716
|
-
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, renders: 0, lang: "", stars: [] },
|
|
717
|
-
places: { ...(this.#placeLayer?.stats ?? { places: 0, shown: 0, labels: 0, renders: 0 }) },
|
|
919
|
+
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, pick: null, hover: null, constellations: 0, culture: "iau", renders: 0, lang: "", stars: [] },
|
|
920
|
+
places: { ...(this.#placeLayer?.stats ?? { places: 0, shown: 0, labels: 0, renders: 0, marks: 0, groups: 0, sprites: 0, omitted: 0 }) },
|
|
718
921
|
cityNames: this.#cities?.stats ?? { on: false, max: 0, radius: 0, tiers: [], cities: 0, names: 0, renders: 0 },
|
|
922
|
+
borders: { ...this.#model.borders.stats, shown: { ...this.#model.borders.stats.shown }, loaded: [...this.#model.borders.stats.loaded] },
|
|
923
|
+
grid: { ...this.#model.grid.stats },
|
|
924
|
+
countryNames: this.#countries?.stats ?? { on: false, max: 0, countries: 0, names: 0, renders: 0, failed: false },
|
|
719
925
|
};
|
|
720
926
|
}
|
|
721
927
|
/**
|
|
@@ -825,16 +1031,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
825
1031
|
if (satellite)
|
|
826
1032
|
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite) }, bubbles: true, composed: true }));
|
|
827
1033
|
};
|
|
828
|
-
|
|
829
|
-
// Ctrl, Command, Alt and Shift with the wheel are the family's own and are left alone.
|
|
830
|
-
#wheel = (event) => {
|
|
831
|
-
if (!this.hasAttribute("immersive") || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey)
|
|
832
|
-
return;
|
|
833
|
-
event.preventDefault();
|
|
834
|
-
event.stopImmediatePropagation();
|
|
835
|
-
const pixels = event.deltaMode === 1 ? event.deltaY * 33 : event.deltaMode === 2 ? event.deltaY * 800 : event.deltaY;
|
|
836
|
-
this.dispatchEvent(new WheelEvent("wheel", { deltaY: Math.max(-250, Math.min(250, pixels)) * WHEEL_AS_PINCH, deltaMode: 0, clientX: event.clientX, clientY: event.clientY, ctrlKey: true, bubbles: true, cancelable: true, composed: true }));
|
|
837
|
-
};
|
|
1034
|
+
#wheel = (event) => immersiveWheel(this, event);
|
|
838
1035
|
/** The view as it is (for a page that wants to read it back). */
|
|
839
1036
|
get view() {
|
|
840
1037
|
return { ...this.#model.view };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The host's styles in the immersive mode: any shape of box, and a touch drag that turns the view instead of scrolling the page. */
|
|
2
|
+
export declare const IMMERSIVE_STYLE = ":host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}";
|
|
3
|
+
/**
|
|
4
|
+
* In an immersive view a plain wheel zooms. It is passed on to the shared hands as the wheel's own pinch (Ctrl and a small step), so whichever hands hold the view (the element's, or a bar bound to it) apply it with their
|
|
5
|
+
* limits; Ctrl, Command, Alt and Shift with the wheel are the family's own and are left alone. Listen with `{ capture: true, passive: false }`, before the shared hands.
|
|
6
|
+
*/
|
|
7
|
+
export declare function immersiveWheel(host: HTMLElement, event: WheelEvent): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The full-screen mode of the 3D elements (the `immersive` attribute): the element fills its box in any shape, a plain wheel zooms instead of scrolling the page, and a touch drag turns the view.
|
|
2
|
+
/** The plain wheel in an immersive view is a pinch of this share: a notch (100) zooms about 1.2 times, as the family's mouse wheel does with Alt. */
|
|
3
|
+
const WHEEL_AS_PINCH = 0.2;
|
|
4
|
+
/** The host's styles in the immersive mode: any shape of box, and a touch drag that turns the view instead of scrolling the page. */
|
|
5
|
+
export const IMMERSIVE_STYLE = ":host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}";
|
|
6
|
+
/**
|
|
7
|
+
* In an immersive view a plain wheel zooms. It is passed on to the shared hands as the wheel's own pinch (Ctrl and a small step), so whichever hands hold the view (the element's, or a bar bound to it) apply it with their
|
|
8
|
+
* limits; Ctrl, Command, Alt and Shift with the wheel are the family's own and are left alone. Listen with `{ capture: true, passive: false }`, before the shared hands.
|
|
9
|
+
*/
|
|
10
|
+
export function immersiveWheel(host, event) {
|
|
11
|
+
if (!host.hasAttribute("immersive") || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey)
|
|
12
|
+
return;
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
event.stopImmediatePropagation();
|
|
15
|
+
const pixels = event.deltaMode === 1 ? event.deltaY * 33 : event.deltaMode === 2 ? event.deltaY * 800 : event.deltaY;
|
|
16
|
+
host.dispatchEvent(new WheelEvent("wheel", { deltaY: Math.max(-250, Math.min(250, pixels)) * WHEEL_AS_PINCH, deltaMode: 0, clientX: event.clientX, clientY: event.clientY, ctrlKey: true, bubbles: true, cancelable: true, composed: true }));
|
|
17
|
+
}
|
|
@@ -9,5 +9,12 @@ export { BODY_LABEL_ATTRIBUTES, bodyLabelText, readBodyLabel, loadMichroma, setB
|
|
|
9
9
|
export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VERT, airFor, airFrag, airTop, readAirThickness, type AirSamples } from "./air.ts";
|
|
10
10
|
export { AIR_NOTE } from "./air-note.ts";
|
|
11
11
|
export type { SkyLabelStyle } from "../sky/style.ts";
|
|
12
|
+
export type { SkyKeepClear } from "../sky/keep-clear.ts";
|
|
12
13
|
export { CITY_NAMES_DEFAULT, CITY_NAMES_MAX, TIER_RADIUS, cityNameText, cityRank, cityTiersFor, layoutCities, nameWidth, readCityNames, type CityFrame, type CityLayoutOptions, type CityName, type CityNameTier, type NamedCity } from "../cities/geometry.ts";
|
|
13
14
|
export { CITY_NAMES_ATTRIBUTES, type CityNamesStyle } from "../cities/host.ts";
|
|
15
|
+
export { BORDER_ATTRIBUTES, BORDER_REGIONS_RADIUS, codesNear, readBorders, shapeBoxes, sharedEdges, type BorderFeature, type BorderSets, type BorderShapes } from "../borders/lines.ts";
|
|
16
|
+
export type { BorderData, BorderStats } from "../borders/layer.ts";
|
|
17
|
+
export { EARTH_TILT, GRID_ATTRIBUTES, GRID_FINE_RADIUS, gridLines, readGrid, type GridLines } from "../grid/lines.ts";
|
|
18
|
+
export type { GridStats } from "../grid/layer.ts";
|
|
19
|
+
export { COUNTRY_LETTER_SPACING, COUNTRY_NAMES_ATTRIBUTES, COUNTRY_NAMES_DEFAULT, COUNTRY_NAMES_MAX, countryNameBox, countryNameText, countrySpots, layoutCountryNames, readCountryNames, type CountryFrame, type CountryLayoutOptions, type CountryName, type CountrySpots, type NamedShape } from "../country-names/geometry.ts";
|
|
20
|
+
export type { CountryNamesStats, CountryNamesStyle } from "../country-names/host.ts";
|
package/dist/realistic/index.js
CHANGED
|
@@ -11,3 +11,6 @@ export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VER
|
|
|
11
11
|
export { AIR_NOTE } from "./air-note.js";
|
|
12
12
|
export { CITY_NAMES_DEFAULT, CITY_NAMES_MAX, TIER_RADIUS, cityNameText, cityRank, cityTiersFor, layoutCities, nameWidth, readCityNames } from "../cities/geometry.js";
|
|
13
13
|
export { CITY_NAMES_ATTRIBUTES } from "../cities/host.js";
|
|
14
|
+
export { BORDER_ATTRIBUTES, BORDER_REGIONS_RADIUS, codesNear, readBorders, shapeBoxes, sharedEdges } from "../borders/lines.js";
|
|
15
|
+
export { EARTH_TILT, GRID_ATTRIBUTES, GRID_FINE_RADIUS, gridLines, readGrid } from "../grid/lines.js";
|
|
16
|
+
export { COUNTRY_LETTER_SPACING, COUNTRY_NAMES_ATTRIBUTES, COUNTRY_NAMES_DEFAULT, COUNTRY_NAMES_MAX, countryNameBox, countryNameText, countrySpots, layoutCountryNames, readCountryNames } from "../country-names/geometry.js";
|