@johnmorrisdotca/wakusei-planets 0.63.0 → 0.64.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 CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.64.0] - 2026-11-17
6
+
7
+ - **`/sky`: sky events through astronomy-engine, experimental: `seasons`, Moon phases, eclipses, planet rise/set/transit, libration, lunar apsides and nodes, greatest elongation** (MODULES-534; John Morris, 2026-11-17). A new entry, `@johnmorrisdotca/wakusei-planets/sky`, over astronomy-engine as an **optional peer dependency** (`>=2.1.19 <3`; the lockfile is unchanged, the devDependency stays at 2.1.19). `seasons(year)` gives the March equinox, June solstice, September equinox and December solstice as `Date`s (UTC); 16 events in 1900, 2000, 2026 and 2050 are within 60 seconds of the US Naval Observatory's table (the table is to the minute). Only `src/sky.ts` imports the peer, and a test holds that no other entry point's import graph reaches it. `/sky` is 30.6 kB gzipped with the peer's bytes counted (the budget line is added for `./sky` only; the Moon and eclipse searches pull in most of astronomy-engine's series). New guide, "Sky events" (空の出来事), in both languages. Every choice below is a **default, for John to confirm**: the `./sky` entry with the optional peer; a missing peer is the runtime's own error from a static import (the plan preferred a top-level `await import()` with a worded error, but the size measure targets ES2020, which refuses top-level await, so the plan's fallback is used); new types without the `Deg` suffix; events marked `@experimental`; Jupiter's moons and constellations not wrapped.
8
+ - **`/sky`, part 2: calendar-day rise and set, alignments, peak magnitude, local solar eclipses, lunar eclipse magnitude** (MODULES-534, part 2; John Morris, 2026-11-17). Five more experimental functions in `/sky`, each held to a published reference with the worst error printed by its test:
9
+ - **`riseSetTimes(body, date, { observer, timeZone })`**: rise, transit and set over one calendar day of an IANA time zone (23, 24 or 25 hours on a clock-change day), with `horizon: "crosses" | "above" | "below"` for the poles. `timeZone` is required: a missing, empty or unknown one is a `RangeError` that names it. Against the USNO's one-day service (New York on 1 November and 8 March 2026, Sydney on 4 October, Tromso on the midnight-sun and polar-night days): 22 events, the worst 28.9 s (the table is to the minute); an event the USNO puts outside the zone's day is `null`; the Sun up all day, down all day and the Moon up all day are `"above"`, `"below"`, `"above"`.
10
+ - **`nextAlignment(body, from, { kind: "conjunction" | "opposition" | "quadrature", within })`**: by apparent ecliptic longitude, the name saying so, not `/nearest`'s closest approach. Returns `{ time, kind, side, inferior }`. Against JPL Horizons' ecliptic longitudes (five events: Jupiter and Mars oppositions, Venus's superior and inferior conjunctions, Saturn's western quadrature): the worst 4.7 minutes. Mercury and Venus have conjunctions only (asking for more throws).
11
+ - **`nextPeakMagnitude("venus", from)`**: Venus only, because astronomy-engine finds a peak for no other body (the error says where to look instead: `nextAlignment` opposition for the outer planets, `nextMoonPhase` full for the Moon). Against JPL Horizons' magnitudes: 1.9 days and 0.029 magnitudes from the vertex of a curve that is flat to 0.003 over 4 days.
12
+ - **`localSolarEclipse(from, { observer, within })`**: contacts C1, C2, maximum, C3, C4 as `{ time, altitude }` with the obscuration. Against NASA GSFC's central-line table for 12 August 2026 (eclipse.gsfc.nasa.gov, `SEpath/SEpath2001/SE2026Aug12Tpath.html`), six points over the Atlantic and Spain at NASA's own positions: total at each, the peak within 7.1 s of NASA's UT minute (the engine runs about 6.5 s early at all six; NASA's delta-T is 71.4 s and it leaves out the limb profile), the central duration within 2.2 s and the Sun's altitude within 0.52 degree. No city positions are used. Annular eclipses have no reference checked.
13
+ - **Lunar eclipse magnitude**: `findEclipses` now gives each lunar eclipse its umbral `magnitude` (negative for a penumbral one), worked out from the engine's own shadow geometry, against NASA's column for all 22 eclipses of 2021 to 2030: the worst 0.006.
14
+ - The alignment search walks a day at a time and settles to 0.1 s, so an event within a quarter of a second before `from` counts as at it. No new dependency. The `./sky` size baseline goes from 30,624 to 33,317 bytes gzipped (this Mac's zlib; the new functions and the day arithmetic), on purpose; no other baseline is changed.
15
+ - **Greatest elongation** (`nextGreatestElongation`, Mercury and Venus), against the vertex of a parabola through JPL Horizons' Sun-observer-target angles: Mercury (19 February 2026) 3.7 minutes and 0.0005 degrees, Venus (15 August 2026) 7.4 minutes and 0.0008 degrees.
16
+ - **Lunar apsides and nodes** (`lunarApsides`, `lunarNodes`), against JPL Horizons for November 2026: the ascending node 22 s from where the Moon's ecliptic latitude is zero; the perigee and apogee 6.2 and 6.7 minutes from where the range rate is zero (a measured limit of astronomy-engine, not a doubt about the test: the distance at the extreme is within 0.6 km and 42 km). The search settles to about 0.1 s, so an interval's ends are exact only to that.
17
+ - **Libration** (`moonLibration`), against JPL Horizons for 14 days of November 2026: 0.007 degrees in longitude, 0.024 in latitude (the physical libration of up to 0.04 is not added), and up to 51 km in the Moon's distance, which the engine runs short by smoothly.
18
+ - **Planet rise, set and transit** (`nextRise`, `nextSet`, `nextTransit` for the Sun, the Moon and the planets), against JPL Horizons rise/transit/set for the seven planets at Tokyo on 8 and 9 November 2026: all 42 events fall in the minute before Horizons' stamp (-59.4 to -0.7 s from it); the Sun's rise and set agree with `/suncalc` within 10 s. The search settles to about 0.1 s, so "the start is included" holds to a quarter of a second. Calendar-day `riseSetTimes` with a time zone is not here yet.
19
+ - **Eclipses** (`findEclipses`), against NASA's predictions for 2021 to 2030 (Fred Espenak, NASA GSFC): all 22 solar and 22 lunar eclipses found, none more, of NASA's type (a hybrid is reported by its kind at the greatest moment); greatest eclipse within 9 s (solar) and 13 s (lunar) of NASA's TD less 69 s of delta-T. An annular eclipse's obscuration is within 0.03 of NASA's magnitude squared. Lunar magnitudes and local circumstances are not wrapped yet.
20
+ - **Moon phases** (`moonPhases`, `nextMoonPhase`), against the USNO table of 2026: all 50 phases in order, the engine 11 to 80 seconds after the table's minute stamp (the table drops the seconds); this package's own Moon puts each found phase at 0, 0.25, 0.5 or 0.75 of its cycle to within 0.016 (the Moon's latitude).
21
+
22
+ - **`goTo(id)` and `ride(id)` take the id of an asteroid of `/asteroids`** (MODULES-1354). With the option `asteroids` on, `space.goTo("eros")` brings the camera to a few times the asteroid's size from it (200 km at least) looking at it and keeps it there as the clock runs, and `space.ride("apophis")` puts the camera at the asteroid looking at the Sun (`view: "follow"` and `distanceKm` keep a distance instead). Both are at the true scale: the view is set to it, and going back to `compressed`, turning the option off, a `goTo` of a body or `ride(null)` ends the move. `riding.target.id` says which asteroid (`RidePoint` has an optional `id`), `wakusei-ride` is sent and `wakusei-hop` is not. `europa` and `dione` stay moons; `asteroid:europa` (the prefix works for every id) means the asteroid. With the option off an asteroid's id throws a `RangeError` that says to turn it on; with it on a name that is no body and no asteroid throws one that says so; a name that is neither, with the option off, returns `false` as before. A call made before the records are in is made when they are, unless another move is asked for first. `ride` takes any string in its type now (`RideTarget | string`), and `goTo` an option `distanceKm`. The ids are a list of their own in the view (`src/space/asteroid-ids.ts`, 1 kB, held to the table by a test), so the table is still not loaded until the option is on. Test: `e2e/space-asteroid-goto.demo.ts`, five repeats under throttle 4.
23
+
24
+ - **The asteroids of `/asteroids` can be placed in the space view, named and pressed** (MODULES-1353). The attribute and property `asteroids` (off by default) puts the 104 bodies in the view: each a point on its orbit with the belts' points in the one instanced draw, the nearest few (at most 12, within about an astronomical unit in the true scale) named in the page's language, each an entry of `sight()` with the new kind `small-body`, and a press on a name sends `wakusei-body-click` (`{ id, name, kind: "small-body" }`) and `wakusei-asteroid-click` (`{ id, name }`) and goes nowhere (going to an asteroid is `goTo` and `ride`, MODULES-1354). `asteroidsSource()` in `/asteroids` is the same bodies as a data-door source. Nothing is loaded, worked out or drawn for them with the option off (the table is a chunk the space view reaches only by a dynamic import, and the table's test now says so); on, a draw gives the graphics card one more call (14 to 15) and holds six more GPU objects (105 to 111), and turned off again it is back to 14 and 105 frame for frame; a frame took a median of 66 ms and 89 ms at the 95th percentile off, 74 and 106 ms on, and at a quarter of the CPU 81 and 100 ms off, 77 and 119 ms on; placing the 104 bodies took a median of 0.1 ms and at most 0.9 ms a draw (Chromium in software, 24 draws each, 2026-11-17). Two asteroids, `europa` and `dione`, have the id of a moon of the package: the view keeps them apart, the moon is still the moon, and events and `sight()` say `kind: "small-body"` for the asteroid. `stats.asteroids` says how many were placed and named. Test: `e2e/space-asteroids.demo.ts`, five repeats under throttle 4.
25
+
26
+ - **A tumbling view no longer jumps where the controller's angles fold** (MODULES-545). While the shared controller tumbles the view about all three axes (turn axis `all`), `<wakusei-body>` drew the pose from the controller's `yaw`, `tilt` and `roll`, which fold at a pole (`(yaw, tilt, roll)` and `(yaw + 180, 180 - tilt, roll + 180)` are the same orientation), and the element's own composition (yaw about the body's pole, then tilt, then roll with the roll's sign reversed) is not a smooth function of the controller's orientation: the pole or the meridian jumped by 20 degrees or more in one frame of a smooth tumble. During a tumble yaw now turns the whole picture about the picture's vertical and the roll keeps the controller's sign, which makes the pose follow the orientation (the biggest step of a simulated tumble is 1.2 degrees, its own); the moons and their orbit lines follow. Every other view is as it was: yaw about the pole for a drag, a key or Auto-turn on one axis. The one visible change is at the moment the turn axis is set to `all` or taken off it, when a body whose pole is tipped in the picture takes its new pose at once. Tests: `test/tumble.test.ts` (kazoku-ui's own orientation tumbled past the pole; the old pose's jump is asserted too; an upright pole gives the same pose both ways). The public API is unchanged (`test/api-snapshot.txt` moves only for the class's private members).
27
+
28
+ - **A press on a drawn name picks its body** (MODULES-1510; found on spaceprogramx.com by John Morris, 2026-11-18: pressing Oberon and Umbriel at Uranus did nothing). The space view's hover found a body within 14 pixels of its place or, failing that, inside a drawn name's box, but a press looked at the 14 pixels only, so a press on a name, 30 to 50 pixels from its dot, was taken for one on the empty sky (the names are for the eye and the keyboard: `pointer-events` is off on them). A press now asks the hover's own hit test, so what lights up under the pointer is what a press picks, by mouse and by touch. A press on a disc still works with `labels="off"`. A name the view draws on the body itself (`data-carried`) has no box of its own and is still pressed on the body. `e2e/space-press-names.demo.ts`. The API snapshot is renewed: it lists the private `#bodyAt`, which takes a third argument now; no public name or signature changed.
29
+
30
+ - **`<wakusei-surface>` `position.up` follows the view while driving** (MODULES-1487). The getter always returned the standing eye height (1.7 m). While the rover is driven (`drive="on"`) or the landing watched it now returns the height the view is drawn from over the ground under it: the commander's seat in the seat view, the chase camera in the chase view. Standing is unchanged.
31
+
5
32
  ## [0.63.0] - 2026-11-17
6
33
 
7
34
  - **A drop-in for suncalc 2.1 and 1.9: both flags, default exports, a guide** (MODULES-535). `getTimes` and `getMoonTimes` in `/suncalc` now give `alwaysUp` and `alwaysDown` both, one `true` and one `false`, on a day without a sunrise or without a Moon rise and set, as suncalc 2 does (before, only the true one was there). `/suncalc` and `/suncalc/legacy` each have a default export holding the same functions and the same `times` array, for code written `import SunCalc from "suncalc"`. A new guide, "Replacing suncalc" (English and Japanese), has the one-line import change, every function side by side, the three conventions people trip on, the differences kept on purpose, the measured limits, and suncalc3's extras listed and not built. `test/suncalc-grid.test.ts` runs every function against suncalc 2.1.2 and suncalc 1.9.0 (dev-only) on fourteen places (both hemispheres, both polar circles, 78 degrees north and south) by eleven days from 1900 to 2100 by three times of day; `test/docs-replacing-suncalc.test.ts` runs the guide's examples. The API snapshot was updated for the two default exports.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
19
19
 
20
20
  <p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
21
21
 
22
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.63.0/docs/images/lineup-desk.png" width="640"></p>
22
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.64.0/docs/images/lineup-desk.png" width="640"></p>
23
23
 
24
24
  ## Who it is for
25
25
 
@@ -412,7 +412,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
412
412
 
413
413
  ## The portrait builder
414
414
 
415
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.63.0/docs/images/portrait-family.png" width="640"></p>
415
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.64.0/docs/images/portrait-family.png" width="640"></p>
416
416
 
417
417
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
418
418
 
@@ -529,6 +529,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
529
529
  | [Serve it yourself](docs/guides/serve-it-yourself.md) | A small Node server over the package, that you host |
530
530
  | [The Sun and Moon from a place](docs/guides/suncalc.md) | Position, sunrise and sunset, Moon rise, set and phase; a drop-in for suncalc |
531
531
  | [Where the planets are in the sky](docs/guides/sky-bodies.md) | The Sun, the Moon and the planets for a moment and a place: right ascension and declination of date and J2000, magnitude, size, phase, elongation, azimuth and altitude, as plain data |
532
+ | [Sky events (experimental)](docs/guides/sky-events.md) | When the seasons begin, through astronomy-engine as an optional peer; more events to come |
532
533
  | [Coordinate conversions](docs/guides/coordinates.md) | Pure spherical, ecliptic, equatorial and horizontal coordinate conversions |
533
534
  | [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
534
535
  | [How it works](docs/guides/how-it-works.md) | Where the numbers come from |
@@ -567,7 +568,7 @@ BODIES.pluto.kind; // "dwarf-planet"
567
568
 
568
569
  If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
569
570
 
570
- > Morris, J. (2026). *Wakusei Planets* (version 0.63.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
571
+ > Morris, J. (2026). *Wakusei Planets* (version 0.64.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
571
572
 
572
573
  Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
573
574
 
@@ -1,4 +1,4 @@
1
- import type { SmallBody } from "./door/small-bodies.ts";
1
+ import type { SmallBody, SmallBodySource } from "./door/small-bodies.ts";
2
2
  import { type Vec3 } from "./vec.ts";
3
3
  import { type When } from "./when.ts";
4
4
  export type { When } from "./when.ts";
@@ -395,3 +395,17 @@ export declare const ASTEROID_ACCURACY: {
395
395
  /** In words, what the numbers leave out. */
396
396
  readonly note: "Two-body motion: the planets' pull is not included, so a body that passes close to the Earth or Jupiter, and every body far from its epoch, drifts further. Positions of near-Earth asteroids a year or more from the epoch are a guide, not an ephemeris.";
397
397
  };
398
+ /**
399
+ * The bodies as a record source of the data door, the way the view draws them as points beside the belts: every body of the set as a `SmallBody`, in the order of `asteroidList()`. `<wakusei-space>` adds it for
400
+ * its attribute `asteroids`; a page can hand it to a view's `sources` too.
401
+ *
402
+ * @returns The source.
403
+ *
404
+ * @example
405
+ * ```ts
406
+ * import { asteroidsSource } from "@johnmorrisdotca/wakusei-planets/asteroids";
407
+ *
408
+ * console.log(asteroidsSource().info.id, asteroidsSource().info.licence.name);
409
+ * ```
410
+ */
411
+ export declare function asteroidsSource(): SmallBodySource;
package/dist/asteroids.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // (`asteroidPosition`) or astronomical units (`asteroidPositionAu`, the unit `heliocentric` gives the planets in). The Kepler solver is the package's own. Pure: no DOM, no clock reads, no three.js.
4
4
  import { ASTEROID_FETCHED, ASTEROID_TABLE } from "./data/asteroids.js";
5
5
  import { toTerrestrialTime } from "./clock.js";
6
+ import { madeHere } from "./door/made.js";
6
7
  import { heliocentric, kepler } from "./ephemeris.js";
7
8
  import { length, RAD, sub } from "./vec.js";
8
9
  import { moment } from "./when.js";
@@ -336,3 +337,30 @@ export const ASTEROID_ACCURACY = {
336
337
  /** In words, what the numbers leave out. */
337
338
  note: "Two-body motion: the planets' pull is not included, so a body that passes close to the Earth or Jupiter, and every body far from its epoch, drifts further. Positions of near-Earth asteroids a year or more from the epoch are a guide, not an ephemeris.",
338
339
  };
340
+ /**
341
+ * The bodies as a record source of the data door, the way the view draws them as points beside the belts: every body of the set as a `SmallBody`, in the order of `asteroidList()`. `<wakusei-space>` adds it for
342
+ * its attribute `asteroids`; a page can hand it to a view's `sources` too.
343
+ *
344
+ * @returns The source.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * import { asteroidsSource } from "@johnmorrisdotca/wakusei-planets/asteroids";
349
+ *
350
+ * console.log(asteroidsSource().info.id, asteroidsSource().info.licence.name);
351
+ * ```
352
+ */
353
+ export function asteroidsSource() {
354
+ return madeHere({
355
+ kind: "records",
356
+ info: {
357
+ id: "wakusei-asteroids",
358
+ name: { en: "Named asteroids and comets of the Small-Body Database", ja: "小天体データベースの、名前のついた小惑星と彗星" },
359
+ credit: { en: "Asteroid orbits: NASA/JPL Small-Body Database", ja: "小惑星の軌道:NASA/JPL 小天体データベース" },
360
+ licence: { name: "Public domain (NASA/JPL: not subject to copyright in the United States)", url: "https://www.nasa.gov/nasa-brand-center/images-and-media/" },
361
+ url: "https://ssd-api.jpl.nasa.gov/doc/sbdb.html",
362
+ retrieved: ASTEROID_FETCHED,
363
+ },
364
+ records: () => Promise.resolve(ASTEROIDS.map((body) => asteroidAsSmallBody(body))),
365
+ });
366
+ }
@@ -0,0 +1,4 @@
1
+ /** Marks a source object as made by this package. */
2
+ export declare function madeHere<T extends object>(source: T): T;
3
+ /** True for a source object this package made (`tilesSource`), false for any other. */
4
+ export declare const isOwnSource: (source: object) => boolean;
@@ -0,0 +1,10 @@
1
+ // Which source objects this package made, apart from `own.ts` (which holds the credits of the package's own data, and the picture credits with them) so that an entry point that only needs to mark a source, such as `/asteroids`, does not carry them. Pure.
2
+ /** The source objects this package made itself: only these are its own, whatever id a caller's source gives itself. */
3
+ const MADE_HERE = new WeakSet();
4
+ /** Marks a source object as made by this package. */
5
+ export function madeHere(source) {
6
+ MADE_HERE.add(source);
7
+ return source;
8
+ }
9
+ /** True for a source object this package made (`tilesSource`), false for any other. */
10
+ export const isOwnSource = (source) => MADE_HERE.has(source);
@@ -13,10 +13,7 @@ import type { Credit, SourceInfo } from "../data-door.ts";
13
13
  export declare const OWN_SOURCES: readonly SourceInfo[];
14
14
  /** The rows of `OWN_SOURCES` by id. */
15
15
  export declare const OWN_BY_ID: ReadonlyMap<string, SourceInfo>;
16
- /** Marks a source object as made by this package. */
17
- export declare function madeHere<T extends object>(source: T): T;
18
- /** True for a source object this package made (`tilesSource`), false for any other. */
19
- export declare const isOwnSource: (source: object) => boolean;
16
+ export { isOwnSource, madeHere } from "./made.ts";
20
17
  /**
21
18
  * The credit of one of the package's own sources, for a page that draws something itself: the pictures and positions of the elements are credited by the elements' own `credits()`, and a page that draws a body from the
22
19
  * painter puts `ownCredit("wakusei-pictures", 1)` in its credit line.
package/dist/door/own.js CHANGED
@@ -55,15 +55,7 @@ export const OWN_SOURCES = freeze([
55
55
  ]);
56
56
  /** The rows of `OWN_SOURCES` by id. */
57
57
  export const OWN_BY_ID = new Map(OWN_SOURCES.map((source) => [source.id, source]));
58
- /** The source objects this package made itself: only these are its own, whatever id a caller's source gives itself. */
59
- const MADE_HERE = new WeakSet();
60
- /** Marks a source object as made by this package. */
61
- export function madeHere(source) {
62
- MADE_HERE.add(source);
63
- return source;
64
- }
65
- /** True for a source object this package made (`tilesSource`), false for any other. */
66
- export const isOwnSource = (source) => MADE_HERE.has(source);
58
+ export { isOwnSource, madeHere } from "./made.js";
67
59
  /**
68
60
  * The credit of one of the package's own sources, for a page that draws something itself: the pictures and positions of the elements are credited by the elements' own `credits()`, and a page that draws a body from the
69
61
  * painter puts `ownCredit("wakusei-pictures", 1)` in its credit line.
package/dist/element.js CHANGED
@@ -17,6 +17,7 @@ import { createDoorHost } from "./door/host.js";
17
17
  import { ownCredit } from "./door/own.js";
18
18
  export { TEXTURE_BASE, TEXTURE_FAR_BASE, TILES_BASE } from "./scene/textures.js";
19
19
  import { mapWidthOf, ringWidthOf, zoomLimit } from "./scene/reach.js";
20
+ import { viewPose } from "./scene/tumble.js";
20
21
  import { createBodyItem } from "./scene/body.js";
21
22
  import { NAME_LABEL_ATTRIBUTES, nameLabelKey, nameLabelText, readNameLabel } from "./scene/name-label.js";
22
23
  import { delegates, onRegister } from "./scene/store.js";
@@ -50,11 +51,6 @@ const readTime = (value) => {
50
51
  return Number.isFinite(ms) ? ms : undefined;
51
52
  };
52
53
  const vectorKey = (v) => `${v[0].toFixed(2)},${v[1].toFixed(2)},${v[2].toFixed(2)}`;
53
- function turnPose(pose, axis, degrees) {
54
- pose.pole = turnVec(pose.pole, axis, degrees);
55
- pose.meridian = turnVec(pose.meridian, axis, degrees);
56
- pose.light = turnVec(pose.light, axis, degrees);
57
- }
58
54
  /** Keep the body in the picture: at least a quarter of its width stays inside the edge, however far the view is moved. `pan` is in half-widths of the picture. */
59
55
  function clampPan(pan, extent, zoom) {
60
56
  const half = extent / Math.max(0.05, zoom);
@@ -133,6 +129,8 @@ export class WakuseiBody extends HTMLElement {
133
129
  #tilt = 0;
134
130
  #roll = 0;
135
131
  #pitchDelta = 0;
132
+ /** True while the shared controller tumbles the view about all three axes: the pose is then drawn so it follows the controller's orientation (`scene/tumble.ts`). */
133
+ #tumble = false;
136
134
  #lastAnchors = -1;
137
135
  #zoom = 1;
138
136
  #panX = 0;
@@ -627,7 +625,10 @@ export class WakuseiBody extends HTMLElement {
627
625
  this.#handsKey = key;
628
626
  const limits = this.#limits();
629
627
  this.#limitKey = `${limits.zoomMax}|${this.look}`;
630
- this.#hands = carryControls(this, { on, limits, grabRadius: this.discRadius, objectSize: { width: this.discRadius * 2, height: this.discRadius * 2 }, onChange: (view) => this.setView(view) });
628
+ this.#hands = carryControls(this, { on, limits, grabRadius: this.discRadius, objectSize: { width: this.discRadius * 2, height: this.discRadius * 2 }, onChange: (view) => {
629
+ this.#tumble = this.#hands?.controller.turnAxis === "all";
630
+ this.setView(view);
631
+ } });
631
632
  if (this.#zoom !== 1 || this.#yaw !== 0 || this.#tilt !== 0 || this.#panX !== 0 || this.#panY !== 0 || this.#roll !== 0) {
632
633
  if (!this.hasAttribute("data-kazoku-bar"))
633
634
  this.setView({});
@@ -748,18 +749,12 @@ export class WakuseiBody extends HTMLElement {
748
749
  }
749
750
  // --- the state of the scene --------------------------------------------------------------------------------------------------------------------
750
751
  #sceneOf(frame) {
751
- const pose = { pole: frame.pose.pole, meridian: frame.pose.meridian, light: frame.pose.light };
752
752
  const tiltBy = this.#pitchDelta - this.#tilt;
753
- if (this.#yaw !== 0)
754
- pose.meridian = turnVec(pose.meridian, pose.pole, this.#yaw);
755
- if (tiltBy !== 0)
756
- turnPose(pose, [1, 0, 0], tiltBy);
757
- const roll = -this.#roll;
758
- if (roll !== 0)
759
- turnPose(pose, [0, 0, 1], roll);
753
+ const roll = this.#tumble ? this.#roll : -this.#roll;
754
+ const pose = viewPose(frame.pose, this.#yaw, tiltBy, roll, this.#tumble);
760
755
  const r = this.#request();
761
756
  const extent = this.#extent(r.moons);
762
- const moons = r.moons ? this.#moonsOf(frame, extent, tiltBy, roll) : undefined;
757
+ const moons = r.moons ? this.#moonsOf(frame, extent, tiltBy, roll, this.#tumble ? this.#yaw : 0) : undefined;
763
758
  const label = this.#labelNow();
764
759
  return { pose, extent, sky: frame.time !== undefined, zoom: this.#zoom, panX: clampPan(this.#panX, extent, this.#zoom), panY: clampPan(this.#panY, extent, this.#zoom), moons, label };
765
760
  }
@@ -818,32 +813,34 @@ export class WakuseiBody extends HTMLElement {
818
813
  this.#limitKey = key;
819
814
  this.#hands.setLimits(limits);
820
815
  }
821
- #moonsOf(frame, extent, tilt, roll) {
816
+ #moonsOf(frame, extent, tilt, roll, spin) {
822
817
  const moons = [];
823
818
  for (const m of frame.moons) {
824
819
  if (m.distance <= extent * 1.05) {
825
820
  const orbit = this.#orbits.get(m.id);
826
- const tipped = tilt === 0 ? [m.x, m.y, m.z] : turnVec([m.x, m.y, m.z], [1, 0, 0], tilt);
821
+ const spun = spin === 0 ? [m.x, m.y, m.z] : turnVec([m.x, m.y, m.z], [0, 1, 0], spin);
822
+ const tipped = tilt === 0 ? spun : turnVec(spun, [1, 0, 0], tilt);
827
823
  const rotated = roll === 0 ? tipped : turnVec(tipped, [0, 0, 1], roll);
828
- moons.push({ id: m.id, x: rotated[0], y: rotated[1], z: rotated[2], orbit: orbit === undefined || (tilt === 0 && roll === 0) ? orbit : this.#tiltedOrbit(m.id, orbit, tilt, roll) });
824
+ moons.push({ id: m.id, x: rotated[0], y: rotated[1], z: rotated[2], orbit: orbit === undefined || (spin === 0 && tilt === 0 && roll === 0) ? orbit : this.#tiltedOrbit(m.id, orbit, tilt, roll, spin) });
829
825
  }
830
826
  }
831
827
  return moons;
832
828
  }
833
829
  #tilted = new Map();
834
- #tiltedOrbit(id, orbit, tilt, roll) {
830
+ #tiltedOrbit(id, orbit, tilt, roll, spin) {
835
831
  const held = this.#tilted.get(id);
836
- if (held !== undefined && held.source === orbit && held.tilt === tilt && held.roll === roll)
832
+ if (held !== undefined && held.source === orbit && held.tilt === tilt && held.roll === roll && held.spin === spin)
837
833
  return held.out;
838
834
  const out = new Float32Array(orbit.length);
839
835
  for (let i = 0; i < orbit.length; i += 3) {
840
- const tipped = turnVec([orbit[i], orbit[i + 1], orbit[i + 2]], [1, 0, 0], tilt);
836
+ const spun = spin === 0 ? [orbit[i], orbit[i + 1], orbit[i + 2]] : turnVec([orbit[i], orbit[i + 1], orbit[i + 2]], [0, 1, 0], spin);
837
+ const tipped = turnVec(spun, [1, 0, 0], tilt);
841
838
  const v = roll === 0 ? tipped : turnVec(tipped, [0, 0, 1], roll);
842
839
  out[i] = v[0];
843
840
  out[i + 1] = v[1];
844
841
  out[i + 2] = v[2];
845
842
  }
846
- this.#tilted.set(id, { source: orbit, tilt, roll, out });
843
+ this.#tilted.set(id, { source: orbit, tilt, roll, spin, out });
847
844
  return out;
848
845
  }
849
846
  /** The moons of Jupiter and Saturn follow their theories once those are fetched; until then the fitted orbits answer. */
@@ -0,0 +1,13 @@
1
+ import type { Pose } from "../ephemeris.ts";
2
+ /**
3
+ * The pose for a view. Usually `yaw` turns the body about its own pole. While the view tumbles (the controller turns it about all three axes) `yaw` turns the whole picture about the picture's vertical,
4
+ * as the controller's own orientation does, because a turn about a pole that is tipped in the picture is not the same pose for the two sets of angles `(yaw, tilt, roll)` and `(yaw + 180, 180 - tilt, roll + 180)`
5
+ * that the controller swaps between at a pole, and the body would jump there.
6
+ * @param base The body's pose before the view.
7
+ * @param yaw Degrees about the pole, or about the picture's vertical while `tumble` is true.
8
+ * @param tilt Degrees about the picture's horizontal axis, as the element turns it (minus the controller's).
9
+ * @param roll Degrees about the line of sight, as the element turns it: minus the controller's roll, except in a tumble, where the controller's roll goes in as it is. The orientation the controller tumbles has the three turns in the opposite handedness to the element's ordinary pose, and with the roll's sign kept the pose is a smooth function of it.
10
+ * @param tumble True while the controller tumbles the view.
11
+ * @returns A new pose.
12
+ */
13
+ export declare function viewPose(base: Pose, yaw: number, tilt: number, roll: number, tumble: boolean): Pose;
@@ -0,0 +1,34 @@
1
+ import { turn } from "../vec.js";
2
+ const VERTICAL = [0, 1, 0];
3
+ const ACROSS = [1, 0, 0];
4
+ const TOWARD = [0, 0, 1];
5
+ function turnAll(pose, axis, degrees) {
6
+ pose.pole = turn(pose.pole, axis, degrees);
7
+ pose.meridian = turn(pose.meridian, axis, degrees);
8
+ pose.light = turn(pose.light, axis, degrees);
9
+ }
10
+ /**
11
+ * The pose for a view. Usually `yaw` turns the body about its own pole. While the view tumbles (the controller turns it about all three axes) `yaw` turns the whole picture about the picture's vertical,
12
+ * as the controller's own orientation does, because a turn about a pole that is tipped in the picture is not the same pose for the two sets of angles `(yaw, tilt, roll)` and `(yaw + 180, 180 - tilt, roll + 180)`
13
+ * that the controller swaps between at a pole, and the body would jump there.
14
+ * @param base The body's pose before the view.
15
+ * @param yaw Degrees about the pole, or about the picture's vertical while `tumble` is true.
16
+ * @param tilt Degrees about the picture's horizontal axis, as the element turns it (minus the controller's).
17
+ * @param roll Degrees about the line of sight, as the element turns it: minus the controller's roll, except in a tumble, where the controller's roll goes in as it is. The orientation the controller tumbles has the three turns in the opposite handedness to the element's ordinary pose, and with the roll's sign kept the pose is a smooth function of it.
18
+ * @param tumble True while the controller tumbles the view.
19
+ * @returns A new pose.
20
+ */
21
+ export function viewPose(base, yaw, tilt, roll, tumble) {
22
+ const pose = { pole: base.pole, meridian: base.meridian, light: base.light };
23
+ if (yaw !== 0) {
24
+ if (tumble)
25
+ turnAll(pose, VERTICAL, yaw);
26
+ else
27
+ pose.meridian = turn(pose.meridian, pose.pole, yaw);
28
+ }
29
+ if (tilt !== 0)
30
+ turnAll(pose, ACROSS, tilt);
31
+ if (roll !== 0)
32
+ turnAll(pose, TOWARD, roll);
33
+ return pose;
34
+ }