@johnmorrisdotca/chikyu-earth 0.18.0 → 0.20.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 +9 -0
- package/NOTICE.md +4 -0
- package/README.md +27 -3
- 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/package.json +11 -4
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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",
|
|
@@ -122,6 +122,11 @@
|
|
|
122
122
|
"import": "./dist/satellites/index.js",
|
|
123
123
|
"default": "./dist/satellites/index.js"
|
|
124
124
|
},
|
|
125
|
+
"./sheets": {
|
|
126
|
+
"types": "./dist/sheets/index.d.ts",
|
|
127
|
+
"import": "./dist/sheets/index.js",
|
|
128
|
+
"default": "./dist/sheets/index.js"
|
|
129
|
+
},
|
|
125
130
|
"./package.json": "./package.json"
|
|
126
131
|
},
|
|
127
132
|
"files": [
|
|
@@ -163,14 +168,14 @@
|
|
|
163
168
|
},
|
|
164
169
|
"dependencies": {
|
|
165
170
|
"@johnmorrisdotca/chizu": "^1.6.0",
|
|
166
|
-
"@johnmorrisdotca/kazoku-ui": "^0.
|
|
171
|
+
"@johnmorrisdotca/kazoku-ui": "^0.24.0",
|
|
167
172
|
"d3-geo": "^3.1.1"
|
|
168
173
|
},
|
|
169
174
|
"peerDependencies": {
|
|
170
|
-
"
|
|
175
|
+
"@johnmorrisdotca/wakusei-planets": ">=0.5.0",
|
|
171
176
|
"astronomy-engine": ">=2.1.0",
|
|
172
177
|
"satellite.js": ">=6.0.0",
|
|
173
|
-
"
|
|
178
|
+
"three": ">=0.160.0"
|
|
174
179
|
},
|
|
175
180
|
"peerDependenciesMeta": {
|
|
176
181
|
"three": {
|
|
@@ -192,6 +197,8 @@
|
|
|
192
197
|
"@angular/core": "^22.2.4",
|
|
193
198
|
"@angular/platform-browser": "^22.2.4",
|
|
194
199
|
"@eslint/js": "^9.0.0",
|
|
200
|
+
"@johnmorrisdotca/hata": "^1.8.0",
|
|
201
|
+
"@johnmorrisdotca/kuni": "^1.5.0",
|
|
195
202
|
"@johnmorrisdotca/wakusei-planets": "^0.5.0",
|
|
196
203
|
"@playwright/test": "1.64.0",
|
|
197
204
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|