@johnmorrisdotca/chikyu-earth 0.17.0 → 0.19.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 +8 -0
- package/NOTICE.md +4 -0
- package/README.md +51 -15
- package/dist/element.d.ts +4 -0
- package/dist/element.js +26 -2
- package/dist/realistic/element.d.ts +3 -0
- package/dist/realistic/element.js +27 -2
- package/dist/sheets/common.d.ts +50 -0
- package/dist/sheets/common.js +94 -0
- package/dist/sheets/country.d.ts +50 -0
- package/dist/sheets/country.js +70 -0
- package/dist/sheets/earth.d.ts +50 -0
- package/dist/sheets/earth.js +103 -0
- package/dist/sheets/hatch.d.ts +23 -0
- package/dist/sheets/hatch.js +66 -0
- package/dist/sheets/index.d.ts +7 -0
- package/dist/sheets/index.js +9 -0
- package/dist/sheets/land.d.ts +83 -0
- package/dist/sheets/land.js +257 -0
- package/dist/sheets/outline.d.ts +15 -0
- package/dist/sheets/outline.js +116 -0
- package/dist/sheets/sun.d.ts +68 -0
- package/dist/sheets/sun.js +216 -0
- package/dist/sheets/text.d.ts +213 -0
- package/dist/sheets/text.js +244 -0
- package/dist/space/element.d.ts +5 -0
- package/dist/space/element.js +37 -0
- package/package.json +12 -8
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { type ContinentId } from "./land.ts";
|
|
2
|
+
import type { Lang } from "./common.ts";
|
|
3
|
+
/** The Earth's size, from the IAU nominal values (mean radius 6,371 km) and WGS84 (equatorial circumference 40,075 km), rounded: kilometres across, and round the equator. */
|
|
4
|
+
export declare const EARTH_KM: {
|
|
5
|
+
readonly across: 12742;
|
|
6
|
+
readonly round: 40075;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The tilt of the Earth's axis to its orbit, in degrees (the IAU's obliquity of the ecliptic at J2000: 23.4393).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { TILT_DEGREES } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
14
|
+
*
|
|
15
|
+
* console.log(TILT_DEGREES.toFixed(1));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const TILT_DEGREES = 23.4393;
|
|
19
|
+
export type PlaceKind = "continent" | "ocean";
|
|
20
|
+
/**
|
|
21
|
+
* A continent or an ocean, with where its name is written on a globe and on the flat map.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { PLACES, type Place } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
26
|
+
*
|
|
27
|
+
* const africa: Place | undefined = PLACES.find((place) => place.id === "africa");
|
|
28
|
+
* console.log(africa?.en, africa?.ja);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface Place {
|
|
32
|
+
id: string;
|
|
33
|
+
kind: PlaceKind;
|
|
34
|
+
/** The name in lines of words that are written one under the other. */
|
|
35
|
+
en: readonly string[];
|
|
36
|
+
/** The Japanese name as a child reads it (the reading), and the kanji with it for a title. */
|
|
37
|
+
ja: readonly string[];
|
|
38
|
+
kanji: string;
|
|
39
|
+
/** Longitude and latitude where the name is centred. */
|
|
40
|
+
at: readonly [number, number];
|
|
41
|
+
/** Where it is centred on the flat world map, when that is not `at`. */
|
|
42
|
+
mapAt?: readonly [number, number];
|
|
43
|
+
/** On the flat map the name is one line, for the narrow band of sea it is written in. */
|
|
44
|
+
oneLine?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The seven continents and the five oceans the sheets name, with the longitude and latitude where each name is written.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { PLACES } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
52
|
+
*
|
|
53
|
+
* console.log(PLACES.filter((place) => place.kind === "ocean").map((place) => place.en.join(" ")));
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const PLACES: readonly Place[];
|
|
57
|
+
/** A continent's name for a sentence, in one line; Japanese with its kanji. */
|
|
58
|
+
export declare function continentName(id: ContinentId, lang: Lang): string;
|
|
59
|
+
/**
|
|
60
|
+
* The package's name, the credits and the words a sheet carries, by language (the brand in a sheet's header is the page's to pass in).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { SAY } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
65
|
+
*
|
|
66
|
+
* console.log(SAY.en.pack, SAY.ja.day);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const SAY: {
|
|
70
|
+
readonly en: {
|
|
71
|
+
readonly pack: "Chikyu Earth";
|
|
72
|
+
readonly credits: "Outlines: Natural Earth (public domain). Names: kuni. The Sun's place: Meeus, Astronomical Algorithms.";
|
|
73
|
+
readonly day: "Day";
|
|
74
|
+
readonly night: "Night";
|
|
75
|
+
readonly sun: "Sun";
|
|
76
|
+
readonly flag: "Draw the flag!";
|
|
77
|
+
readonly star: "Capital";
|
|
78
|
+
readonly light: "Sunlight";
|
|
79
|
+
readonly spring: "Spring";
|
|
80
|
+
readonly summer: "Summer";
|
|
81
|
+
readonly autumn: "Autumn";
|
|
82
|
+
readonly winter: "Winter";
|
|
83
|
+
readonly months: readonly ["March", "June", "September", "December"];
|
|
84
|
+
readonly colour: "Colour the continents, then the oceans.";
|
|
85
|
+
};
|
|
86
|
+
readonly ja: {
|
|
87
|
+
readonly pack: "Chikyu Earth 地球";
|
|
88
|
+
readonly credits: "ちずの せん: Natural Earth (パブリックドメイン)。なまえ: kuni。たいようの いち: Meeus の けいさん。";
|
|
89
|
+
readonly day: "ひる";
|
|
90
|
+
readonly night: "よる";
|
|
91
|
+
readonly sun: "たいよう";
|
|
92
|
+
readonly flag: "はたを かこう!";
|
|
93
|
+
readonly star: "しゅと";
|
|
94
|
+
readonly light: "ひかり";
|
|
95
|
+
readonly spring: "はる";
|
|
96
|
+
readonly summer: "なつ";
|
|
97
|
+
readonly autumn: "あき";
|
|
98
|
+
readonly winter: "ふゆ";
|
|
99
|
+
readonly months: readonly ["3がつ", "6がつ", "9がつ", "12がつ"];
|
|
100
|
+
readonly colour: "たいりくと うみに いろを ぬろう。";
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* The three views of the globe sheet: the Americas, Europe and Africa, and Asia and Oceania.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { GLOBE_VIEWS } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
109
|
+
*
|
|
110
|
+
* console.log(GLOBE_VIEWS.join(", "));
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const GLOBE_VIEWS: readonly ["americas", "europe-africa", "asia-oceania"];
|
|
114
|
+
/**
|
|
115
|
+
* The name of a view of the globe sheet.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* import { globeSheetSvg, type GlobeView } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
120
|
+
*
|
|
121
|
+
* const view: GlobeView = "asia-oceania";
|
|
122
|
+
* console.log(globeSheetSvg(view, { widthMm: 184.6, heightMm: 170 }).includes("Asia"));
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export type GlobeView = (typeof GLOBE_VIEWS)[number];
|
|
126
|
+
/** The place at the middle of each view, in longitude and latitude. */
|
|
127
|
+
export declare const VIEW_CENTRES: Readonly<Record<GlobeView, readonly [number, number]>>;
|
|
128
|
+
/** Where each name is written on each view of the globe, by place; a name not listed is not on that view. */
|
|
129
|
+
export declare const VIEW_LABELS: Readonly<Record<GlobeView, Readonly<Record<string, readonly [number, number]>>>>;
|
|
130
|
+
/**
|
|
131
|
+
* The title of each kind of sheet, in a language.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { TITLES } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
136
|
+
*
|
|
137
|
+
* console.log(TITLES.globe("americas", "en"), TITLES.country("Japan", "en"), TITLES.seasons("ja"));
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare const TITLES: {
|
|
141
|
+
globe: (view: GlobeView, lang: Lang) => string;
|
|
142
|
+
map: (lang: Lang) => string;
|
|
143
|
+
country: (name: string, lang: Lang) => string;
|
|
144
|
+
daynight: (lang: Lang) => string;
|
|
145
|
+
seasons: (lang: Lang) => string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* The three facts of the globe sheet and of the world map, in plain words. The map's are the share of the land the biggest and the smallest continents have (from the outlines) and the Pacific.
|
|
149
|
+
* @param kind - `globe` or `map`.
|
|
150
|
+
* @param lang - `en` or `ja`.
|
|
151
|
+
* @returns Three sentences.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { earthFacts } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
156
|
+
*
|
|
157
|
+
* console.log(earthFacts("map", "en")[0]);
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function earthFacts(kind: "globe" | "map", lang: Lang): string[];
|
|
161
|
+
/** The moment as words, in UTC: `2026-06-21 12:00 UTC`. */
|
|
162
|
+
export declare const momentText: (ms: number) => string;
|
|
163
|
+
/**
|
|
164
|
+
* The three facts of the day and night sheet for a moment, with the place the Sun is straight overhead then.
|
|
165
|
+
* @param ms - The moment, in milliseconds since the Unix epoch.
|
|
166
|
+
* @param lang - `en` or `ja`.
|
|
167
|
+
* @returns Three sentences.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { dayNightFacts } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
172
|
+
*
|
|
173
|
+
* console.log(dayNightFacts(Date.UTC(2026, 5, 21, 12), "en")[1]);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare function dayNightFacts(ms: number, lang: Lang): string[];
|
|
177
|
+
/**
|
|
178
|
+
* The three facts of the seasons sheet.
|
|
179
|
+
* @param lang - `en` or `ja`.
|
|
180
|
+
* @returns Three sentences.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { seasonsFacts } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
185
|
+
*
|
|
186
|
+
* console.log(seasonsFacts("en")[0]);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function seasonsFacts(lang: Lang): string[];
|
|
190
|
+
/**
|
|
191
|
+
* The three facts of a "my country" sheet: the continent it is in, the countries it touches and its capital.
|
|
192
|
+
* @param shape - The country's name and Japanese name, its continent and the names of its neighbours.
|
|
193
|
+
* @param capital - The capital's name, or `undefined` for a sheet that asks the child to find it.
|
|
194
|
+
* @param lang - `en` or `ja`.
|
|
195
|
+
* @returns Three sentences.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { countryFacts, countryShape } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
200
|
+
*
|
|
201
|
+
* const france = countryShape("FR")!;
|
|
202
|
+
* console.log(countryFacts(france, "Paris", "en")[1]);
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
export declare function countryFacts(shape: {
|
|
206
|
+
name: string;
|
|
207
|
+
ja: string;
|
|
208
|
+
continent: ContinentId;
|
|
209
|
+
neighbours: readonly {
|
|
210
|
+
name: string;
|
|
211
|
+
ja: string;
|
|
212
|
+
}[];
|
|
213
|
+
}, capital: string | undefined, lang: Lang): string[];
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// What the sheets say, in English and Japanese: the names of the continents and oceans (the Japanese with its reading, for a child), the three facts of each sheet and the titles. Every number in a fact is worked out from the package's own
|
|
2
|
+
// outlines and sun, or is one of the few figures of the Earth written below with its source. Pure.
|
|
3
|
+
import { subsolarPoint } from "../realistic/sun.js";
|
|
4
|
+
import { landShares } from "./land.js";
|
|
5
|
+
/** The Earth's size, from the IAU nominal values (mean radius 6,371 km) and WGS84 (equatorial circumference 40,075 km), rounded: kilometres across, and round the equator. */
|
|
6
|
+
export const EARTH_KM = { across: 12742, round: 40075 };
|
|
7
|
+
/**
|
|
8
|
+
* The tilt of the Earth's axis to its orbit, in degrees (the IAU's obliquity of the ecliptic at J2000: 23.4393).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { TILT_DEGREES } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
13
|
+
*
|
|
14
|
+
* console.log(TILT_DEGREES.toFixed(1));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const TILT_DEGREES = 23.4393;
|
|
18
|
+
/**
|
|
19
|
+
* The seven continents and the five oceans the sheets name, with the longitude and latitude where each name is written.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { PLACES } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
24
|
+
*
|
|
25
|
+
* console.log(PLACES.filter((place) => place.kind === "ocean").map((place) => place.en.join(" ")));
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const PLACES = [
|
|
29
|
+
{ id: "north-america", kind: "continent", en: ["North", "America"], ja: ["きた", "アメリカ"], kanji: "北アメリカ", at: [-100, 44], mapAt: [-109, 53] },
|
|
30
|
+
{ id: "south-america", kind: "continent", en: ["South", "America"], ja: ["みなみ", "アメリカ"], kanji: "南アメリカ", at: [-60, -13], mapAt: [-61, -14] },
|
|
31
|
+
{ id: "europe", kind: "continent", en: ["Europe"], ja: ["ヨーロッパ"], kanji: "ヨーロッパ", at: [14, 51], mapAt: [13, 55] },
|
|
32
|
+
{ id: "africa", kind: "continent", en: ["Africa"], ja: ["アフリカ"], kanji: "アフリカ", at: [20, 5], mapAt: [25, 6] },
|
|
33
|
+
{ id: "asia", kind: "continent", en: ["Asia"], ja: ["アジア"], kanji: "アジア", at: [90, 42], mapAt: [127, 46] },
|
|
34
|
+
{ id: "oceania", kind: "continent", en: ["Oceania"], ja: ["オセアニア"], kanji: "オセアニア", at: [134, -25], mapAt: [141, -19] },
|
|
35
|
+
{ id: "antarctica", kind: "continent", en: ["Antarctica"], ja: ["なんきょく"], kanji: "南極大陸", at: [20, -80], mapAt: [-1, -71] },
|
|
36
|
+
{ id: "pacific", kind: "ocean", en: ["Pacific", "Ocean"], ja: ["たいへいよう"], kanji: "太平洋", at: [-145, 8], mapAt: [-128, -6] },
|
|
37
|
+
{ id: "atlantic", kind: "ocean", en: ["Atlantic", "Ocean"], ja: ["たいせいよう"], kanji: "大西洋", at: [-33, 22], mapAt: [-46, 20] },
|
|
38
|
+
{ id: "indian", kind: "ocean", en: ["Indian", "Ocean"], ja: ["インドよう"], kanji: "インド洋", at: [78, -20], mapAt: [62, -33] },
|
|
39
|
+
{ id: "southern", kind: "ocean", en: ["Southern", "Ocean"], ja: ["なんきょくかい"], kanji: "南極海", at: [-30, -62], mapAt: [-39, -48], oneLine: true },
|
|
40
|
+
{ id: "arctic", kind: "ocean", en: ["Arctic", "Ocean"], ja: ["ほっきょくかい"], kanji: "北極海", at: [-30, 83], mapAt: [147, 73], oneLine: true },
|
|
41
|
+
];
|
|
42
|
+
/** A continent's name for a sentence, in one line; Japanese with its kanji. */
|
|
43
|
+
export function continentName(id, lang) {
|
|
44
|
+
const place = PLACES.find((one) => one.id === id);
|
|
45
|
+
return lang === "ja" ? (place.kanji === place.ja.join("") ? place.kanji : `${place.ja.join("")} (${place.kanji})`) : place.en.join(" ");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The package's name, the credits and the words a sheet carries, by language (the brand in a sheet's header is the page's to pass in).
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { SAY } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
53
|
+
*
|
|
54
|
+
* console.log(SAY.en.pack, SAY.ja.day);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const SAY = {
|
|
58
|
+
en: {
|
|
59
|
+
pack: "Chikyu Earth",
|
|
60
|
+
credits: "Outlines: Natural Earth (public domain). Names: kuni. The Sun's place: Meeus, Astronomical Algorithms.",
|
|
61
|
+
day: "Day",
|
|
62
|
+
night: "Night",
|
|
63
|
+
sun: "Sun",
|
|
64
|
+
flag: "Draw the flag!",
|
|
65
|
+
star: "Capital",
|
|
66
|
+
light: "Sunlight",
|
|
67
|
+
spring: "Spring",
|
|
68
|
+
summer: "Summer",
|
|
69
|
+
autumn: "Autumn",
|
|
70
|
+
winter: "Winter",
|
|
71
|
+
months: ["March", "June", "September", "December"],
|
|
72
|
+
colour: "Colour the continents, then the oceans.",
|
|
73
|
+
},
|
|
74
|
+
ja: {
|
|
75
|
+
pack: "Chikyu Earth 地球",
|
|
76
|
+
credits: "ちずの せん: Natural Earth (パブリックドメイン)。なまえ: kuni。たいようの いち: Meeus の けいさん。",
|
|
77
|
+
day: "ひる",
|
|
78
|
+
night: "よる",
|
|
79
|
+
sun: "たいよう",
|
|
80
|
+
flag: "はたを かこう!",
|
|
81
|
+
star: "しゅと",
|
|
82
|
+
light: "ひかり",
|
|
83
|
+
spring: "はる",
|
|
84
|
+
summer: "なつ",
|
|
85
|
+
autumn: "あき",
|
|
86
|
+
winter: "ふゆ",
|
|
87
|
+
months: ["3がつ", "6がつ", "9がつ", "12がつ"],
|
|
88
|
+
colour: "たいりくと うみに いろを ぬろう。",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The three views of the globe sheet: the Americas, Europe and Africa, and Asia and Oceania.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import { GLOBE_VIEWS } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
97
|
+
*
|
|
98
|
+
* console.log(GLOBE_VIEWS.join(", "));
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export const GLOBE_VIEWS = ["americas", "europe-africa", "asia-oceania"];
|
|
102
|
+
/** The place at the middle of each view, in longitude and latitude. */
|
|
103
|
+
export const VIEW_CENTRES = {
|
|
104
|
+
americas: [-78, 8],
|
|
105
|
+
"europe-africa": [24, 10],
|
|
106
|
+
"asia-oceania": [110, 4],
|
|
107
|
+
};
|
|
108
|
+
/** Where each name is written on each view of the globe, by place; a name not listed is not on that view. */
|
|
109
|
+
export const VIEW_LABELS = {
|
|
110
|
+
americas: { "north-america": [-98, 40], "south-america": [-60, -14], pacific: [-104, -4], atlantic: [-52, 20] },
|
|
111
|
+
"europe-africa": { europe: [14, 51], africa: [22, 4], atlantic: [-3, 1], indian: [54, -4], asia: [58, 36] },
|
|
112
|
+
"asia-oceania": { asia: [92, 40], oceania: [134, -25], indian: [82, -8], pacific: [140, 8] },
|
|
113
|
+
};
|
|
114
|
+
const VIEW_NAMES = {
|
|
115
|
+
americas: { en: "The Americas", ja: "アメリカ" },
|
|
116
|
+
"europe-africa": { en: "Europe and Africa", ja: "ヨーロッパと アフリカ" },
|
|
117
|
+
"asia-oceania": { en: "Asia and Oceania", ja: "アジアと オセアニア" },
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The title of each kind of sheet, in a language.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { TITLES } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
125
|
+
*
|
|
126
|
+
* console.log(TITLES.globe("americas", "en"), TITLES.country("Japan", "en"), TITLES.seasons("ja"));
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export const TITLES = {
|
|
130
|
+
globe: (view, lang) => (lang === "ja" ? VIEW_NAMES[view].ja : VIEW_NAMES[view].en),
|
|
131
|
+
map: (lang) => (lang === "ja" ? "せかいちず (世界地図)" : "A map of the world"),
|
|
132
|
+
country: (name, lang) => (lang === "ja" ? `わたしの くに: ${name}` : `My country: ${name}`),
|
|
133
|
+
daynight: (lang) => (lang === "ja" ? "ひると よる (昼と夜)" : "Day and night"),
|
|
134
|
+
seasons: (lang) => (lang === "ja" ? "きせつ (季節)" : "The seasons"),
|
|
135
|
+
};
|
|
136
|
+
// The Pacific is about 165 million square kilometres of sea, all the land about 149 million (NOAA, the National Ocean Service).
|
|
137
|
+
const percent = (value) => Math.round(value);
|
|
138
|
+
const thousands = (value) => value.toLocaleString("en-US");
|
|
139
|
+
/**
|
|
140
|
+
* The three facts of the globe sheet and of the world map, in plain words. The map's are the share of the land the biggest and the smallest continents have (from the outlines) and the Pacific.
|
|
141
|
+
* @param kind - `globe` or `map`.
|
|
142
|
+
* @param lang - `en` or `ja`.
|
|
143
|
+
* @returns Three sentences.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* import { earthFacts } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
148
|
+
*
|
|
149
|
+
* console.log(earthFacts("map", "en")[0]);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export function earthFacts(kind, lang) {
|
|
153
|
+
const { landPercent, continents } = landShares();
|
|
154
|
+
const land = percent(landPercent);
|
|
155
|
+
if (kind === "globe") {
|
|
156
|
+
return lang === "ja"
|
|
157
|
+
? ["たいりくは 7つ、おおきな うみは 5つ。", `りくは ${land}%、うみは ${100 - land}%。`, `はばは ${thousands(EARTH_KM.across)} km、1しゅうは ${thousands(EARTH_KM.round)} km。`]
|
|
158
|
+
: ["The Earth has 7 continents and 5 oceans.", `${land}% is land and ${100 - land}% is sea.`, `${thousands(EARTH_KM.across)} km across, ${thousands(EARTH_KM.round)} km round.`];
|
|
159
|
+
}
|
|
160
|
+
const small = continents.oceania;
|
|
161
|
+
return lang === "ja"
|
|
162
|
+
? [`いちばん おおきい たいりくは アジア。りくの ${percent(continents.asia)}%。`, `いちばん ちいさい たいりくは オセアニア。りくの ${percent(small)}%。`, "いちばん おおきい うみは たいへいよう。りくを ぜんぶ あわせたより おおきい。"]
|
|
163
|
+
: [`Asia is the biggest continent: ${percent(continents.asia)}% of the land.`, `Oceania is the smallest: ${percent(small)}% of the land.`, "The Pacific is bigger than all the land put together."];
|
|
164
|
+
}
|
|
165
|
+
/** The sun's place as words: `23.4° N, 120.1° E`. */
|
|
166
|
+
const place = ([lon, lat]) => `${Math.abs(lat).toFixed(1)}° ${lat >= 0 ? "N" : "S"}, ${Math.abs(lon).toFixed(1)}° ${lon >= 0 ? "E" : "W"}`;
|
|
167
|
+
/** The moment as words, in UTC: `2026-06-21 12:00 UTC`. */
|
|
168
|
+
export const momentText = (ms) => `${new Date(ms).toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
169
|
+
/**
|
|
170
|
+
* The three facts of the day and night sheet for a moment, with the place the Sun is straight overhead then.
|
|
171
|
+
* @param ms - The moment, in milliseconds since the Unix epoch.
|
|
172
|
+
* @param lang - `en` or `ja`.
|
|
173
|
+
* @returns Three sentences.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* import { dayNightFacts } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
178
|
+
*
|
|
179
|
+
* console.log(dayNightFacts(Date.UTC(2026, 5, 21, 12), "en")[1]);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export function dayNightFacts(ms, lang) {
|
|
183
|
+
const sun = subsolarPoint(ms);
|
|
184
|
+
const where = place([sun.lon, sun.lat]);
|
|
185
|
+
return lang === "ja"
|
|
186
|
+
? ["たいように てらされる はんぶんが ひる、はんたいがわの はんぶんが よるです。", `${momentText(ms)} に たいようが まうえに くるのは ${where} です。`, "ちきゅうは 1にちで 1まわり するので、ひると よるの さかいは 1じかんに 15ど すすみます。"]
|
|
187
|
+
: ["The Sun lights half of the Earth. There it is day. The other half has night.", `At ${momentText(ms)} the Sun is straight overhead at ${where}.`, "The Earth turns once a day, so the line between day and night moves 15 degrees every hour."];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The three facts of the seasons sheet.
|
|
191
|
+
* @param lang - `en` or `ja`.
|
|
192
|
+
* @returns Three sentences.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* import { seasonsFacts } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
197
|
+
*
|
|
198
|
+
* console.log(seasonsFacts("en")[0]);
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export function seasonsFacts(lang) {
|
|
202
|
+
const tilt = TILT_DEGREES.toFixed(1);
|
|
203
|
+
return lang === "ja"
|
|
204
|
+
? [`●は きたきょく。ちきゅうは 1ねんじゅう ${tilt}ど かたむいています。`, "6がつは きたが たいように かたむき、きたは なつです。", "ちきゅうは 365にちで たいようを 1しゅう します。"]
|
|
205
|
+
: [`The dot is the North Pole. The Earth stays tilted ${tilt} degrees.`, "In June the north leans to the Sun, so it is summer in the north.", "The Earth goes round the Sun in about 365 days."];
|
|
206
|
+
}
|
|
207
|
+
/** Up to three names in a sentence: `A, B and C`, or `A, B, C and 2 more`. */
|
|
208
|
+
function nameList(names, lang) {
|
|
209
|
+
const shown = names.slice(0, 3);
|
|
210
|
+
const more = names.length - shown.length;
|
|
211
|
+
if (lang === "ja")
|
|
212
|
+
return shown.join("、") + (more > 0 ? ` ほか ${more}` : "");
|
|
213
|
+
return shown.length === 1 ? shown[0] : `${shown.slice(0, -1).join(", ")} and ${shown.at(-1)}` + (more > 0 ? ` (and ${more} more)` : "");
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The three facts of a "my country" sheet: the continent it is in, the countries it touches and its capital.
|
|
217
|
+
* @param shape - The country's name and Japanese name, its continent and the names of its neighbours.
|
|
218
|
+
* @param capital - The capital's name, or `undefined` for a sheet that asks the child to find it.
|
|
219
|
+
* @param lang - `en` or `ja`.
|
|
220
|
+
* @returns Three sentences.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* import { countryFacts, countryShape } from "@johnmorrisdotca/chikyu-earth/sheets";
|
|
225
|
+
*
|
|
226
|
+
* const france = countryShape("FR")!;
|
|
227
|
+
* console.log(countryFacts(france, "Paris", "en")[1]);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export function countryFacts(shape, capital, lang) {
|
|
231
|
+
const near = shape.neighbours.map((one) => (lang === "ja" ? one.ja : one.name));
|
|
232
|
+
if (lang === "ja") {
|
|
233
|
+
return [
|
|
234
|
+
`${shape.ja}は ${continentName(shape.continent, "ja")} に あります。`,
|
|
235
|
+
near.length === 0 ? "りくで つながっている くには ありません。まわりは うみです。" : `${near.length}つの くにと せっして います: ${nameList(near, "ja")}。`,
|
|
236
|
+
capital === undefined ? "しゅとは どこかな? ★を かこう。" : `しゅとは ${capital} です。 ★の ところです。`,
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
return [
|
|
240
|
+
`${shape.name} is in ${continentName(shape.continent, "en")}.`,
|
|
241
|
+
near.length === 0 ? "No other country touches it by land. The sea is all round it." : `It touches ${near.length} ${near.length === 1 ? "country" : "countries"}: ${nameList(near, "en")}.`,
|
|
242
|
+
capital === undefined ? "Where is the capital city? Draw a star on it." : `The capital city is ${capital}. It is at the star.`,
|
|
243
|
+
];
|
|
244
|
+
}
|
package/dist/space/element.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
1
2
|
import type { GeoPoint } from "../types.ts";
|
|
2
3
|
import { setThreeLoader } from "../realistic/shared.ts";
|
|
3
4
|
import type { LightMode } from "../realistic/earth.ts";
|
|
@@ -117,6 +118,8 @@ type SatelliteStats = {
|
|
|
117
118
|
/**
|
|
118
119
|
* The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
|
|
119
120
|
*
|
|
121
|
+
* It carries kazoku-ui's controls itself: a drag turns the view, two fingers pinch, Ctrl and the wheel zoom (a plain wheel at Fit scrolls the page) and the arrow keys, + and - work once it is focused. The zoom runs from a millionth of Fit (the whole solar system) to 2.5 times, and from 0.5 to 6 times while riding from a body. `controls="none"` turns the hands off; `zoom-min` and `zoom-max` change the range. A `<kazoku-view-controls for="...">` on the element takes the hands over, and the page applies its events with `setView`.
|
|
122
|
+
*
|
|
120
123
|
* @example
|
|
121
124
|
* ```ts no-run
|
|
122
125
|
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
@@ -130,6 +133,8 @@ type SatelliteStats = {
|
|
|
130
133
|
export declare class ChikyuSpace extends HTMLElement {
|
|
131
134
|
#private;
|
|
132
135
|
static observedAttributes: string[];
|
|
136
|
+
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
137
|
+
get controller(): ViewController | undefined;
|
|
133
138
|
connectedCallback(): void;
|
|
134
139
|
disconnectedCallback(): void;
|
|
135
140
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
package/dist/space/element.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
1
2
|
import { adoptStyles } from "../adopt.js";
|
|
2
3
|
import { createGate, frameCap } from "../realistic/gate.js";
|
|
3
4
|
import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
|
|
@@ -38,6 +39,12 @@ const EARTH_RATE = 360 / 86_164.0905;
|
|
|
38
39
|
const SATELLITE_RATE = 360 / (88 * 60);
|
|
39
40
|
const SATELLITE_COLORS = ["#ffd54f", "#7fd4ff", "#ff8fa3", "#9ef0a8"];
|
|
40
41
|
const REAL_TIME_TICK_MS = 60_000;
|
|
42
|
+
/**
|
|
43
|
+
* Tilt to the poles. The zoom is the camera's distance: a millionth of Fit takes in the whole solar system (the views of the planets and their distances need that much), and 2.5 times is as close as the Earth's 4096 pixel picture and the body textures stay sharp.
|
|
44
|
+
* Riding at a body looking at the Earth, the zoom only narrows the camera's field a little either way: 0.5 to 6.
|
|
45
|
+
*/
|
|
46
|
+
const LIMITS = { tiltMax: 90, zoomMin: 0.000001, zoomMax: 2.5 };
|
|
47
|
+
const RIDE_ZOOM = { "zoom-min": "0.5", "zoom-max": "6" };
|
|
41
48
|
const readCentre = (value) => {
|
|
42
49
|
if (!value)
|
|
43
50
|
return null;
|
|
@@ -56,6 +63,8 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
56
63
|
/**
|
|
57
64
|
* The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
|
|
58
65
|
*
|
|
66
|
+
* It carries kazoku-ui's controls itself: a drag turns the view, two fingers pinch, Ctrl and the wheel zoom (a plain wheel at Fit scrolls the page) and the arrow keys, + and - work once it is focused. The zoom runs from a millionth of Fit (the whole solar system) to 2.5 times, and from 0.5 to 6 times while riding from a body. `controls="none"` turns the hands off; `zoom-min` and `zoom-max` change the range. A `<kazoku-view-controls for="...">` on the element takes the hands over, and the page applies its events with `setView`.
|
|
67
|
+
*
|
|
59
68
|
* @example
|
|
60
69
|
* ```ts no-run
|
|
61
70
|
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
@@ -87,6 +96,12 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
87
96
|
#names = {};
|
|
88
97
|
#hint = "choose to look at it";
|
|
89
98
|
#tiers = {};
|
|
99
|
+
#hands;
|
|
100
|
+
#ridden = {};
|
|
101
|
+
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
102
|
+
get controller() {
|
|
103
|
+
return this.#hands?.controller;
|
|
104
|
+
}
|
|
90
105
|
connectedCallback() {
|
|
91
106
|
this.#model.centre = readCentre(this.getAttribute("center")) ?? this.#model.centre;
|
|
92
107
|
this.#mode = readTime(this.getAttribute("time"));
|
|
@@ -148,10 +163,14 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
148
163
|
this.#last = performance.now();
|
|
149
164
|
this.#schedule();
|
|
150
165
|
this.addEventListener("pointerdown", this.#down);
|
|
166
|
+
this.#hands = carryControls(this, { initial: this.#model.view, limits: LIMITS, onChange: (state, info) => this.setView(state, info.final) });
|
|
151
167
|
this.#labelBox.addEventListener("click", this.#labelClick);
|
|
152
168
|
this.#labelBox.addEventListener("focusin", this.#labelFocus);
|
|
153
169
|
}
|
|
154
170
|
disconnectedCallback() {
|
|
171
|
+
this.#hands?.unbind();
|
|
172
|
+
this.#hands = undefined;
|
|
173
|
+
this.#zoomRange(false);
|
|
155
174
|
this.removeEventListener("pointerdown", this.#down);
|
|
156
175
|
window.removeEventListener("pointerup", this.#up, true);
|
|
157
176
|
clearTimeout(this.#timer);
|
|
@@ -320,6 +339,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
320
339
|
else if (wasRiding)
|
|
321
340
|
model.focus = this.#focusBeforeRide;
|
|
322
341
|
}
|
|
342
|
+
this.#zoomRange(model.ride?.view === "from");
|
|
323
343
|
this.#lostTold = false;
|
|
324
344
|
const pose = model.pose;
|
|
325
345
|
model.transition = (options.smooth ?? true) && !reduced && pose.valid ? { start: performance.now(), duration: 1200, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
|
|
@@ -328,6 +348,23 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
328
348
|
this.#gate?.request();
|
|
329
349
|
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
330
350
|
}
|
|
351
|
+
/** From a body the zoom only narrows the field a little, so the range is 0.5 to 6: the `zoom-min` and `zoom-max` attributes, unless the page set them itself. */
|
|
352
|
+
#zoomRange(from) {
|
|
353
|
+
for (const name of ["zoom-min", "zoom-max"]) {
|
|
354
|
+
const mine = this.#ridden[name];
|
|
355
|
+
if (this.hasAttribute(name) && this.getAttribute(name) !== mine)
|
|
356
|
+
continue;
|
|
357
|
+
if (from) {
|
|
358
|
+
this.#ridden[name] = RIDE_ZOOM[name];
|
|
359
|
+
this.setAttribute(name, RIDE_ZOOM[name]);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
if (mine !== undefined)
|
|
363
|
+
this.removeAttribute(name);
|
|
364
|
+
delete this.#ridden[name];
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
331
368
|
/** What the camera is riding along with now, or null. */
|
|
332
369
|
get riding() {
|
|
333
370
|
const ride = this.#model.ride;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on where you are, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"earth",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"starlink",
|
|
40
40
|
"celestrak",
|
|
41
41
|
"spaceprogramx",
|
|
42
|
+
"space-program-x",
|
|
42
43
|
"spx",
|
|
43
44
|
"space",
|
|
44
45
|
"satellite",
|
|
@@ -121,6 +122,11 @@
|
|
|
121
122
|
"import": "./dist/satellites/index.js",
|
|
122
123
|
"default": "./dist/satellites/index.js"
|
|
123
124
|
},
|
|
125
|
+
"./sheets": {
|
|
126
|
+
"types": "./dist/sheets/index.d.ts",
|
|
127
|
+
"import": "./dist/sheets/index.js",
|
|
128
|
+
"default": "./dist/sheets/index.js"
|
|
129
|
+
},
|
|
124
130
|
"./package.json": "./package.json"
|
|
125
131
|
},
|
|
126
132
|
"files": [
|
|
@@ -162,19 +168,16 @@
|
|
|
162
168
|
},
|
|
163
169
|
"dependencies": {
|
|
164
170
|
"@johnmorrisdotca/chizu": "^1.6.0",
|
|
171
|
+
"@johnmorrisdotca/kazoku-ui": "^0.22.0",
|
|
165
172
|
"d3-geo": "^3.1.1"
|
|
166
173
|
},
|
|
167
174
|
"peerDependencies": {
|
|
168
|
-
"@johnmorrisdotca/
|
|
169
|
-
"three": ">=0.160.0",
|
|
175
|
+
"@johnmorrisdotca/wakusei-planets": ">=0.5.0",
|
|
170
176
|
"astronomy-engine": ">=2.1.0",
|
|
171
177
|
"satellite.js": ">=6.0.0",
|
|
172
|
-
"
|
|
178
|
+
"three": ">=0.160.0"
|
|
173
179
|
},
|
|
174
180
|
"peerDependenciesMeta": {
|
|
175
|
-
"@johnmorrisdotca/kazoku-ui": {
|
|
176
|
-
"optional": true
|
|
177
|
-
},
|
|
178
181
|
"three": {
|
|
179
182
|
"optional": true
|
|
180
183
|
},
|
|
@@ -194,7 +197,8 @@
|
|
|
194
197
|
"@angular/core": "^22.2.4",
|
|
195
198
|
"@angular/platform-browser": "^22.2.4",
|
|
196
199
|
"@eslint/js": "^9.0.0",
|
|
197
|
-
"@johnmorrisdotca/
|
|
200
|
+
"@johnmorrisdotca/hata": "^1.8.0",
|
|
201
|
+
"@johnmorrisdotca/kuni": "^1.5.0",
|
|
198
202
|
"@johnmorrisdotca/wakusei-planets": "^0.5.0",
|
|
199
203
|
"@playwright/test": "1.64.0",
|
|
200
204
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|