@johnmorrisdotca/wakusei-planets 0.75.0 → 0.75.2
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 +26 -1
- package/NOTICE.md +17 -7
- package/README.md +6 -6
- package/dist/asteroids.d.ts +13 -13
- package/dist/asteroids.js +8 -8
- package/dist/bodies/dwarfs.js +1 -1
- package/dist/bodies/earth-look.js +1 -1
- package/dist/bodies/jupiter.js +1 -1
- package/dist/bodies/mars.js +1 -1
- package/dist/bodies/minor.js +23 -2
- package/dist/bodies/moons-neptune.js +1 -1
- package/dist/bodies/moons-pluto.js +2 -0
- package/dist/bodies/moons-saturn.js +1 -1
- package/dist/bodies/neptune.js +1 -1
- package/dist/bodies/pluto.js +1 -0
- package/dist/bodies/saturn.js +1 -1
- package/dist/bodies/uranus.js +1 -1
- package/dist/bodies/venus.js +1 -1
- package/dist/data/asteroids.js +0 -3
- package/dist/data/discovery.js +30 -0
- package/dist/data/estimated-moons.js +354 -354
- package/dist/data/minor.js +6 -0
- package/dist/data/moon-catalogue.d.ts +1 -1
- package/dist/data/moon-catalogue.js +368 -368
- package/dist/data/orbits.js +3 -0
- package/dist/data/shapes/arrokoth-craft.d.ts +2 -0
- package/dist/data/shapes/arrokoth-craft.js +8 -0
- package/dist/data/shapes/bennu-craft.d.ts +2 -0
- package/dist/data/shapes/bennu-craft.js +8 -0
- package/dist/data/shapes/eros-craft.d.ts +2 -0
- package/dist/data/shapes/eros-craft.js +8 -0
- package/dist/facts.d.ts +2 -2
- package/dist/facts.js +10 -4
- package/dist/moon-catalogue.d.ts +9 -9
- package/dist/moon-catalogue.js +11 -10
- package/dist/moon-pages/element.js +0 -2
- package/dist/moon-pages/hero.d.ts +1 -4
- package/dist/moon-pages/hero.js +5 -10
- package/dist/picture-credits.d.ts +1 -1
- package/dist/picture-credits.js +7 -1
- package/dist/place-radii.d.ts +1 -13
- package/dist/place-radii.js +1 -5
- package/dist/places.d.ts +1 -1
- package/dist/places.js +1 -1
- package/dist/portrait/model.js +3 -3
- package/dist/scene/body.d.ts +1 -0
- package/dist/scene/body.js +27 -8
- package/dist/scene/craft.d.ts +30 -0
- package/dist/scene/craft.js +63 -0
- package/dist/scene/glsl.js +3 -1
- package/dist/scene/look.d.ts +20 -0
- package/dist/scene/look.js +19 -0
- package/dist/scene/name-label.d.ts +10 -0
- package/dist/scene/name-label.js +93 -1
- package/dist/scene/painter.d.ts +2 -1
- package/dist/scene/painter.js +49 -4
- package/dist/scene/textures.d.ts +2 -2
- package/dist/shape-basis.d.ts +1 -1
- package/dist/shape-basis.js +2 -0
- package/dist/space/asteroid-ids.d.ts +1 -1
- package/dist/space/asteroid-ids.js +2 -2
- package/dist/space/bodies.js +1 -1
- package/dist/space/element.d.ts +18 -4
- package/dist/space/element.js +27 -5
- package/dist/space/frame.d.ts +1 -1
- package/dist/space/regions.d.ts +1 -1
- package/dist/space/scene.d.ts +2 -2
- package/dist/space/scene.js +3 -2
- package/dist/stops.js +3 -1
- package/dist/textures/arrokoth-craft-512.webp +0 -0
- package/dist/textures/bennu-craft-512.webp +0 -0
- package/dist/textures/eros-craft-512.webp +0 -0
- package/dist/textures/pluto-1024.webp +0 -0
- package/dist/textures/pluto-512.webp +0 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/moon-pages/hero.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// The hero above a moon page's tabs: the planet's edge, and its main moons in an arc, farthest at the top. Disc sizes follow the moons' own diameters, squeezed so a small moon stays visible. No DOM.
|
|
2
|
-
import { BODIES, ringReach } from "../facts.js";
|
|
3
1
|
/** The moons in the hero's arc, farthest from the planet first. Jupiter's four are the Galileans. Saturn's seven are the large named moons. */
|
|
4
2
|
export const HERO_ARC = {
|
|
5
3
|
jupiter: ["callisto", "ganymede", "europa", "io"],
|
|
@@ -14,20 +12,17 @@ export const HERO_SMALL = {
|
|
|
14
12
|
uranus: [],
|
|
15
13
|
neptune: [],
|
|
16
14
|
};
|
|
17
|
-
/** Where the painted face is turned, in degrees, so the familiar side of the planet meets the moons. Jupiter's longitude is the package's best-known side, turned so the Great Red Spot sits in the visible half. Saturn's pitch looks over the pole: the near half of the rings, the one drawn in front of the globe, then crosses the lower part of the globe. A negative pitch puts that half on the upper globe and the far half, which the globe hides, on the lower. */
|
|
15
|
+
/** Where the painted face is turned, in degrees, so the familiar side of the planet meets the moons. Jupiter's longitude is the package's best-known side, turned so the Great Red Spot sits in the visible half. Jupiter's and Saturn's pitch looks over the pole: the near half of the rings, the one drawn in front of the globe, then crosses the lower part of the globe, and the ring is an ellipse. A negative pitch puts that half on the upper globe and the far half, which the globe hides, on the lower. */
|
|
18
16
|
export const HERO_POSE = {
|
|
19
|
-
jupiter: { meridian: 70, tilt: 14 },
|
|
17
|
+
jupiter: { meridian: 70, tilt: 14, pitch: 22 },
|
|
20
18
|
saturn: { meridian: 30, tilt: 26.73, pitch: 22 },
|
|
21
19
|
uranus: { meridian: 10, tilt: 16 },
|
|
22
20
|
neptune: { meridian: 20, tilt: 16 },
|
|
23
21
|
};
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
*/
|
|
22
|
+
/** How far a hero planet is zoomed. 1 frames the globe and its rings, so the ring is the ellipse of the ring plane. Zooming in until the globe filled the frame made Jupiter's wide faint ring the rectangle of the picture. */
|
|
23
|
+
const HERO_ZOOM = { jupiter: 1, saturn: 1, uranus: 1, neptune: 1 };
|
|
27
24
|
export function heroZoom(host) {
|
|
28
|
-
|
|
29
|
-
return 1;
|
|
30
|
-
return Math.max(1.06, ringReach(BODIES[host]) * 1.04);
|
|
25
|
+
return HERO_ZOOM[host];
|
|
31
26
|
}
|
|
32
27
|
/** The hero's moons for one planet, farthest first, in the arc from the upper left down toward the planet's limb. A moon that is not drawn is left out. */
|
|
33
28
|
export function heroMoons(cards, host, lang) {
|
|
@@ -20,7 +20,7 @@ export interface PictureCredit {
|
|
|
20
20
|
readonly en: string;
|
|
21
21
|
readonly ja: string;
|
|
22
22
|
};
|
|
23
|
-
/** What this package changed, from the table's "What was done" column. Present for a CC BY 4.0 map, which asks that changes be named. */
|
|
23
|
+
/** What this package changed, from the table's "What was done" column. Present for a CC BY 4.0 map, which asks that changes be named, and for Pluto, whose south was not photographed and whose far side was seen only at low resolution. */
|
|
24
24
|
readonly changes?: {
|
|
25
25
|
readonly en: string;
|
|
26
26
|
readonly ja: string;
|
package/dist/picture-credits.js
CHANGED
|
@@ -31,7 +31,13 @@ export const PICTURE_CREDITS = [
|
|
|
31
31
|
}),
|
|
32
32
|
cc("uranus", 'This work is based on "Uranus" (https://sketchfab.com/3d-models/uranus-0009a69dbace44608c0bd09af9ba20db) by NestaEric (https://sketchfab.com/Nestaeric) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)', "NestaEric(https://sketchfab.com/Nestaeric)による「Uranus」(https://sketchfab.com/3d-models/uranus-0009a69dbace44608c0bd09af9ba20db)をもとにしています。ライセンスは CC-BY-4.0(http://creativecommons.org/licenses/by/4.0/)です", "The band half of the texture, which has a bright spot, resized to 512, 1024 and 2048.", "明るい斑のある帯の半分を使い、512、1024、2048に縮小しました。"),
|
|
33
33
|
cc("neptune", "Solar System Scope", "Solar System Scope", "Equirectangular map, resized to 512, 1024 and 2048.", "正距円筒図法の地図を、512、1024、2048に縮小しました。"),
|
|
34
|
-
|
|
34
|
+
{
|
|
35
|
+
...pd("pluto", "NASA / Johns Hopkins University Applied Physics Laboratory / Southwest Research Institute", "NASA / Johns Hopkins University Applied Physics Laboratory / Southwest Research Institute"),
|
|
36
|
+
changes: {
|
|
37
|
+
en: "South of about 30 degrees S was not photographed by New Horizons, and the far side only at low resolution; those parts are painted with an image model to continue the photographed ground, keeping the far side's observed broad pattern, and are not observed in detail.",
|
|
38
|
+
ja: "南緯約30度より南はニュー・ホライズンズが撮影しておらず、反対側も低い解像度でしか撮影されていません。それらの部分は、撮影された地面に続くように画像生成モデルで描いたもので、反対側の観測された大まかな模様を保っていますが、細部は観測されたものではありません。撮影された部分は NASA の画像で、パブリックドメインです。",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
35
41
|
cc("sun", "Solar System Scope", "Solar System Scope", "Equirectangular map, resized to 512, 1024 and 2048.", "正距円筒図法の地図を、512、1024、2048に縮小しました。"),
|
|
36
42
|
pd("moon", "NASA's Scientific Visualization Studio (Ernie Wright, Noah Petro); Lunar Reconnaissance Orbiter Camera", "NASA Scientific Visualization Studio(Ernie Wright、Noah Petro)、Lunar Reconnaissance Orbiter Camera"),
|
|
37
43
|
pd("io", "NASA / JPL (Galileo SSI and Voyager images); the file page names no author", "NASA / JPL(Galileo SSIとVoyagerの画像)。ファイルのページに作者の名はありません"),
|
package/dist/place-radii.d.ts
CHANGED
|
@@ -10,32 +10,20 @@ export interface PlaceMeanRadius {
|
|
|
10
10
|
note?: string;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
13
|
+
* The four place bodies `BODIES` has no radius for. Read 2026-11-19, one request a second, from JPL's Small-Body Database except Dimorphos, which is not in it.
|
|
14
14
|
*
|
|
15
|
-
* Eros: diameter 16.84 ± 0.06 km (Yeomans et al. 2000), extents 34.4 × 11.2 × 11.2 km (Veverka et al. 2000).
|
|
16
15
|
* Ryugu: diameter 0.896 ± 0.004 km, extents 1.004 × 0.876 km, two axes (Watanabe et al. 2019).
|
|
17
|
-
* Bennu: diameter 0.48444 ± 0.00030 km, extents 0.5047 × 0.4918 × 0.4567 km (Daly et al. 2020).
|
|
18
16
|
* Dimorphos: volume-equivalent diameter 151 ± 5 m, extents 177 ± 2 × 174 ± 4 × 116 ± 2 m (Daly et al., Nature 2023). The volume is the shape model's, not an ellipsoid of those extents.
|
|
19
17
|
* Tempel 1: diameter 6.0 ± 0.2 km, extents 7.6 × 4.9 km, two axes, preliminary (A'Hearn et al. 2005).
|
|
20
18
|
* 67P: diameter 3.4 ± 0.1 km (Sierks et al. 2015). No extents.
|
|
21
19
|
*/
|
|
22
20
|
export declare const PLACE_MEAN_RADII: {
|
|
23
|
-
readonly eros: {
|
|
24
|
-
readonly radiusKm: 8.42;
|
|
25
|
-
readonly axesKm: readonly [34.4, 11.2, 11.2];
|
|
26
|
-
readonly source: "JPL SBDB: Yeomans et al. 2000; Veverka et al. 2000";
|
|
27
|
-
};
|
|
28
21
|
readonly ryugu: {
|
|
29
22
|
readonly radiusKm: 0.448;
|
|
30
23
|
readonly axesKm: readonly [1.004, 0.876];
|
|
31
24
|
readonly source: "JPL SBDB, Watanabe et al. 2019";
|
|
32
25
|
readonly note: "Two extents only.";
|
|
33
26
|
};
|
|
34
|
-
readonly bennu: {
|
|
35
|
-
readonly radiusKm: 0.24222;
|
|
36
|
-
readonly axesKm: readonly [0.5047, 0.4918, 0.4567];
|
|
37
|
-
readonly source: "JPL SBDB, Daly et al. 2020";
|
|
38
|
-
};
|
|
39
27
|
readonly dimorphos: {
|
|
40
28
|
readonly radiusKm: 0.0755;
|
|
41
29
|
readonly axesKm: readonly [0.177, 0.174, 0.116];
|
package/dist/place-radii.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
// Volume-equivalent mean radii for the place bodies that are not in BODIES. The extents are the published full lengths, two when the source gives two. accuracyKm uses only those extents.
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
3
|
+
* The four place bodies `BODIES` has no radius for. Read 2026-11-19, one request a second, from JPL's Small-Body Database except Dimorphos, which is not in it.
|
|
4
4
|
*
|
|
5
|
-
* Eros: diameter 16.84 ± 0.06 km (Yeomans et al. 2000), extents 34.4 × 11.2 × 11.2 km (Veverka et al. 2000).
|
|
6
5
|
* Ryugu: diameter 0.896 ± 0.004 km, extents 1.004 × 0.876 km, two axes (Watanabe et al. 2019).
|
|
7
|
-
* Bennu: diameter 0.48444 ± 0.00030 km, extents 0.5047 × 0.4918 × 0.4567 km (Daly et al. 2020).
|
|
8
6
|
* Dimorphos: volume-equivalent diameter 151 ± 5 m, extents 177 ± 2 × 174 ± 4 × 116 ± 2 m (Daly et al., Nature 2023). The volume is the shape model's, not an ellipsoid of those extents.
|
|
9
7
|
* Tempel 1: diameter 6.0 ± 0.2 km, extents 7.6 × 4.9 km, two axes, preliminary (A'Hearn et al. 2005).
|
|
10
8
|
* 67P: diameter 3.4 ± 0.1 km (Sierks et al. 2015). No extents.
|
|
11
9
|
*/
|
|
12
10
|
export const PLACE_MEAN_RADII = {
|
|
13
|
-
eros: { radiusKm: 8.42, axesKm: [34.4, 11.2, 11.2], source: "JPL SBDB: Yeomans et al. 2000; Veverka et al. 2000" },
|
|
14
11
|
ryugu: { radiusKm: 0.448, axesKm: [1.004, 0.876], source: "JPL SBDB, Watanabe et al. 2019", note: "Two extents only." },
|
|
15
|
-
bennu: { radiusKm: 0.24222, axesKm: [0.5047, 0.4918, 0.4567], source: "JPL SBDB, Daly et al. 2020" },
|
|
16
12
|
dimorphos: { radiusKm: 0.0755, axesKm: [0.177, 0.174, 0.116], source: "Daly et al., Nature 2023" },
|
|
17
13
|
"tempel-1": { radiusKm: 3, axesKm: [7.6, 4.9], source: "JPL SBDB, A'Hearn et al. 2005", note: "The extents are preliminary, and only two." },
|
|
18
14
|
"67p": { radiusKm: 1.7, source: "JPL SBDB, Sierks et al. 2015", note: "The diameter is 3.4 ± 0.1 km, so the mean radius is uncertain by 0.05 km. The nucleus is two lobes, and the source gives no extents." },
|
package/dist/places.d.ts
CHANGED
|
@@ -242,7 +242,7 @@ export declare function nearestPlace(places: readonly Place[], lat: number, lon:
|
|
|
242
242
|
/**
|
|
243
243
|
* The distance over the surface between two points, and the shape bound on it.
|
|
244
244
|
*
|
|
245
|
-
* `km` is the great circle. On a body in `BODIES` the sphere is the equatorial radius (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). On
|
|
245
|
+
* `km` is the great circle. On a body in `BODIES` the sphere is the equatorial radius (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). On Ryugu, Dimorphos, Tempel 1 and 67P the sphere is the volume-equivalent mean radius.
|
|
246
246
|
*
|
|
247
247
|
* `accuracyKm` is the shape bound: the same angle times half the spread of the published semi-axes. It is `null` when no shape bound is stated, which is a sphere in `BODIES`, and 67P (the source gives no extents; the 0.05 km uncertainty of its mean radius is a note, not this bound).
|
|
248
248
|
*
|
package/dist/places.js
CHANGED
|
@@ -214,7 +214,7 @@ export function nearestPlace(places, lat, lon, ...kinds) {
|
|
|
214
214
|
/**
|
|
215
215
|
* The distance over the surface between two points, and the shape bound on it.
|
|
216
216
|
*
|
|
217
|
-
* `km` is the great circle. On a body in `BODIES` the sphere is the equatorial radius (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). On
|
|
217
|
+
* `km` is the great circle. On a body in `BODIES` the sphere is the equatorial radius (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). On Ryugu, Dimorphos, Tempel 1 and 67P the sphere is the volume-equivalent mean radius.
|
|
218
218
|
*
|
|
219
219
|
* `accuracyKm` is the shape bound: the same angle times half the spread of the published semi-axes. It is `null` when no shape bound is stated, which is a sphere in `BODIES`, and 67P (the source gives no extents; the 0.05 km uncertainty of its mean radius is a note, not this bound).
|
|
220
220
|
*
|
package/dist/portrait/model.js
CHANGED
|
@@ -699,9 +699,9 @@ const POSTER_ARC = {
|
|
|
699
699
|
uranus: ["oberon", "titania", "umbriel", "ariel", "miranda"],
|
|
700
700
|
neptune: ["nereid", "triton", "proteus"],
|
|
701
701
|
};
|
|
702
|
-
/** The turn that puts the familiar face toward the moons. Saturn
|
|
702
|
+
/** The turn that puts the familiar face toward the moons. Jupiter and Saturn look over the pole so the near half of the rings crosses the lower globe and the ring is an ellipse. */
|
|
703
703
|
const POSTER_POSE = {
|
|
704
|
-
jupiter: { spin: 70, tilt: 14 },
|
|
704
|
+
jupiter: { spin: 70, tilt: 14, pitch: 22 },
|
|
705
705
|
saturn: { spin: 30, tilt: 26.73, pitch: 22 },
|
|
706
706
|
uranus: { spin: 10, tilt: 16 },
|
|
707
707
|
neptune: { spin: 20, tilt: 16 },
|
|
@@ -714,7 +714,7 @@ function posterEdge(host) {
|
|
|
714
714
|
const sized = sizesFor(moons, "readable");
|
|
715
715
|
const moonScale = (count <= 4 ? 0.2 : 0.13) / Math.max(...sized);
|
|
716
716
|
const pose = POSTER_POSE[host];
|
|
717
|
-
const planetR =
|
|
717
|
+
const planetR = 0.82 / reachOf(host);
|
|
718
718
|
const planet = {
|
|
719
719
|
body: host,
|
|
720
720
|
x: aspect * 0.92 - planetR * 0.15,
|
package/dist/scene/body.d.ts
CHANGED
package/dist/scene/body.js
CHANGED
|
@@ -2,7 +2,8 @@ import { BODIES } from "../facts.js";
|
|
|
2
2
|
import { silhouette } from "../pose.js";
|
|
3
3
|
import { cross } from "../vec.js";
|
|
4
4
|
import { BALL_FRAGMENT, bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, PAINTED_SURFACE_WINDOWED, RING_FRAGMENT_DETAIL, RING_VERTEX, STAR_GLOW_FRAGMENT, VERTEX } from "./glsl.js";
|
|
5
|
-
import { detailOf, lookOf } from "./look.js";
|
|
5
|
+
import { atmosphereTint, detailOf, lookOf } from "./look.js";
|
|
6
|
+
import { craftGeometry, craftMaterial, craftPicture } from "./craft.js";
|
|
6
7
|
import { shapeGeometry } from "./shape.js";
|
|
7
8
|
import { createDetail } from "./detail.js";
|
|
8
9
|
import { fallbackLook } from "./fallback.js";
|
|
@@ -10,7 +11,7 @@ import { writeBasis } from "./basis.js";
|
|
|
10
11
|
import { interiorOf } from "../interior.js";
|
|
11
12
|
import { loadImage } from "./textures.js";
|
|
12
13
|
import { ringStrip } from "./rings.js";
|
|
13
|
-
import { createNameLabel } from "./name-label.js";
|
|
14
|
+
import { createNameLabel, shapeReach } from "./name-label.js";
|
|
14
15
|
export { fallbackLook } from "./fallback.js";
|
|
15
16
|
/** The shader material of a body: its surface code with the look's lighting and glow uniforms. A star made from numbers is drawn with it too (the size line-up). */
|
|
16
17
|
export function makeBodyMaterial(T, look, painted) {
|
|
@@ -35,7 +36,7 @@ export function makeBodyMaterial(T, look, painted) {
|
|
|
35
36
|
uAmbient: { value: look.ambient ?? 0.04 },
|
|
36
37
|
uLimb: { value: look.limb ?? 0 },
|
|
37
38
|
uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
|
|
38
|
-
uAtmos: { value: new T.Vector3(...(a
|
|
39
|
+
uAtmos: { value: new T.Vector3(...atmosphereTint(a)) },
|
|
39
40
|
uAtmosPow: { value: a?.power ?? 3 },
|
|
40
41
|
uRimBase: { value: 0.12 },
|
|
41
42
|
uEmissive: { value: look.emissive === true ? 1 : 0 },
|
|
@@ -79,13 +80,26 @@ export function createBodyItem(options) {
|
|
|
79
80
|
const wantPainted = (options.look === "painted" || look.mapped === true) && look.painted !== undefined;
|
|
80
81
|
// a moon with a published shape model is the globe moved to its radii (its table is a chunk of its own, waited for here), and then needs no stretching to an ellipsoid
|
|
81
82
|
const shapeTable = look.shape === undefined ? undefined : await look.shape().catch(() => undefined);
|
|
83
|
+
const craft = look.craft === undefined ? undefined : await look.craft().catch(() => undefined);
|
|
82
84
|
// a big picture gets a globe of 192 by 96 steps (as the unshaped sphere has), a tile or a card one of 96 by 48: a page can hold a dozen moons, and the arrays of a globe stay in the page.
|
|
83
85
|
// an estimated rock is coarser: 48 by 24 on a large picture, 24 by 12 on a card, 12 by 6 when it is small, so a page can hold every moon of Jupiter
|
|
84
86
|
const grid = options.coarse === true
|
|
85
87
|
? (Math.min(width, height) >= 280 ? { lon: 48, lat: 24 } : Math.min(width, height) >= 140 ? { lon: 24, lat: 12 } : { lon: 12, lat: 6 })
|
|
86
88
|
: (Math.min(width, height) >= 300 ? { lon: 192, lat: 96 } : { lon: 96, lat: 48 });
|
|
87
|
-
const geometry =
|
|
88
|
-
|
|
89
|
+
const geometry = craft !== undefined
|
|
90
|
+
? assets.acquire(`wk:craft:${held}`, () => craftGeometry(T, craft), (g) => g.dispose())
|
|
91
|
+
: shapeTable === undefined ? assets.acquire("wk:sphere", () => new T.SphereGeometry(1, 192, 96), (g) => g.dispose()) : assets.acquire(`wk:shape:${held}:${grid.lon}`, () => shapeGeometry(T, shapeTable, facts.radiusKm, grid), (g) => g.dispose());
|
|
92
|
+
const shader = craft !== undefined
|
|
93
|
+
? assets.acquire(`wk:body:${held}:craft`, () => craftMaterial(T, look.ambient ?? 0.08), (m) => m.dispose())
|
|
94
|
+
: assets.acquire(`wk:body:${held}:r`, () => makeBodyMaterial(T, look, false), (m) => m.dispose());
|
|
95
|
+
if (craft !== undefined) {
|
|
96
|
+
const picture = await loadImage(T, `${options.textureBase()}${craft.map}`).catch(() => undefined);
|
|
97
|
+
if (picture !== undefined) {
|
|
98
|
+
picture.colorSpace = T.NoColorSpace;
|
|
99
|
+
craftPicture(picture);
|
|
100
|
+
shader.uniforms.uMap.value = assets.acquire(`wk:craftmap:${held}`, () => picture, (t) => t.dispose());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
89
103
|
const paintedMaterial = wantPainted ? assets.acquire(`wk:body:${held}:p`, () => makeBodyMaterial(T, look, true), (m) => m.dispose()) : undefined;
|
|
90
104
|
const materials = paintedMaterial === undefined ? [shader] : [shader, paintedMaterial];
|
|
91
105
|
const baseWrap = look.wrap ?? (look.atmosphere === undefined ? 0.04 : 0.3);
|
|
@@ -285,10 +299,11 @@ export function createBodyItem(options) {
|
|
|
285
299
|
const orient = (state) => {
|
|
286
300
|
const { pole, meridian } = state.pose;
|
|
287
301
|
const east = cross(pole, meridian);
|
|
288
|
-
const
|
|
302
|
+
const measured = shapeTable !== undefined || craft !== undefined;
|
|
303
|
+
const ax = measured ? undefined : facts.axesKm;
|
|
289
304
|
const mean = facts.radiusKm;
|
|
290
305
|
const scaleX = ax ? ax[1] / mean : 1;
|
|
291
|
-
const scaleY = ax ? ax[2] / mean :
|
|
306
|
+
const scaleY = ax ? ax[2] / mean : measured ? 1 : 1 - facts.flattening;
|
|
292
307
|
const scaleZ = ax ? ax[0] / mean : 1;
|
|
293
308
|
setBasis(mesh, east, pole, meridian, scaleX, scaleY, scaleZ);
|
|
294
309
|
if (cut !== undefined)
|
|
@@ -419,6 +434,10 @@ export function createBodyItem(options) {
|
|
|
419
434
|
if (label === undefined) {
|
|
420
435
|
label = createNameLabel(T, state.label.text, state.label, look.emissive === true, () => options.redraw(), facts.colour);
|
|
421
436
|
mesh.add(label.object);
|
|
437
|
+
// a lumpy shape (Thebe, Amalthea, Phobos) stands out past the sphere the name is written on in places: the name is written on the shell that clears its highest point, so no letter is hidden inside the surface
|
|
438
|
+
const reach = shapeReach(geometry);
|
|
439
|
+
if (reach > 1.002)
|
|
440
|
+
label.object.scale.setScalar(reach);
|
|
422
441
|
}
|
|
423
442
|
else {
|
|
424
443
|
label.set(state.label.text, state.label);
|
|
@@ -499,7 +518,7 @@ export function createBodyItem(options) {
|
|
|
499
518
|
},
|
|
500
519
|
get label() {
|
|
501
520
|
const inner = label?.object.children[0];
|
|
502
|
-
return label === undefined || latest.label === undefined || latest.label === null ? null : { shown: label.ready && inner !== undefined && inner.visible, text: latest.label.text, turn: inner?.rotation.y ?? 0, look: label.look };
|
|
521
|
+
return label === undefined || latest.label === undefined || latest.label === null ? null : { shown: label.ready && inner !== undefined && inner.visible, text: latest.label.text, turn: inner?.rotation.y ?? 0, look: label.look, shell: label.object.scale.x };
|
|
503
522
|
},
|
|
504
523
|
resize(w, h) {
|
|
505
524
|
viewWidth = w;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
/**
|
|
3
|
+
* A published mesh, packed so the file stays small: positions, normals and texture coordinates as base64 little-endian floats, and the triangle indices as base64 unsigned shorts.
|
|
4
|
+
* Positions are in units of the body's mean radius, in the globe's frame.
|
|
5
|
+
*/
|
|
6
|
+
export interface CraftMesh {
|
|
7
|
+
/** The picture's file name, in the texture folder. */
|
|
8
|
+
map: string;
|
|
9
|
+
vertices: number;
|
|
10
|
+
positions: string;
|
|
11
|
+
normals: string;
|
|
12
|
+
uvs: string;
|
|
13
|
+
indices: string;
|
|
14
|
+
}
|
|
15
|
+
/** The mesh's arrays, from the packed text. */
|
|
16
|
+
export declare function craftArrays(mesh: CraftMesh): {
|
|
17
|
+
positions: Float32Array;
|
|
18
|
+
normals: Float32Array;
|
|
19
|
+
uvs: Float32Array;
|
|
20
|
+
indices: Uint16Array;
|
|
21
|
+
};
|
|
22
|
+
/** The globe's geometry replaced by the mesh. */
|
|
23
|
+
export declare function craftGeometry(T: Pick<typeof THREE, "BufferGeometry" | "BufferAttribute">, mesh: CraftMesh): THREE.BufferGeometry;
|
|
24
|
+
/** The model's picture uses its own coordinates, with v upward. A texture loader flips a picture, so this puts it back. */
|
|
25
|
+
export declare function craftPicture(texture: {
|
|
26
|
+
flipY: boolean;
|
|
27
|
+
needsUpdate: boolean;
|
|
28
|
+
}): void;
|
|
29
|
+
/** The picture lit by the same sun direction as every other body. The extra uniforms are the ones the body page and the painter write on every material. */
|
|
30
|
+
export declare function craftMaterial(T: Pick<typeof THREE, "ShaderMaterial" | "Vector3">, ambient: number): THREE.ShaderMaterial;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const bytes = (text) => Uint8Array.from(atob(text), (c) => c.charCodeAt(0));
|
|
2
|
+
/** The mesh's arrays, from the packed text. */
|
|
3
|
+
export function craftArrays(mesh) {
|
|
4
|
+
const positions = new Float32Array(bytes(mesh.positions).buffer);
|
|
5
|
+
const normals = new Float32Array(bytes(mesh.normals).buffer);
|
|
6
|
+
const uvs = new Float32Array(bytes(mesh.uvs).buffer);
|
|
7
|
+
const indices = new Uint16Array(bytes(mesh.indices).buffer);
|
|
8
|
+
if (positions.length !== mesh.vertices * 3 || normals.length !== mesh.vertices * 3 || uvs.length !== mesh.vertices * 2)
|
|
9
|
+
throw new RangeError("craft mesh arrays do not match its vertex count");
|
|
10
|
+
return { positions, normals, uvs, indices };
|
|
11
|
+
}
|
|
12
|
+
/** The globe's geometry replaced by the mesh. */
|
|
13
|
+
export function craftGeometry(T, mesh) {
|
|
14
|
+
const { positions, normals, uvs, indices } = craftArrays(mesh);
|
|
15
|
+
const geometry = new T.BufferGeometry();
|
|
16
|
+
geometry.setAttribute("position", new T.BufferAttribute(positions, 3));
|
|
17
|
+
geometry.setAttribute("normal", new T.BufferAttribute(normals, 3));
|
|
18
|
+
geometry.setAttribute("uv", new T.BufferAttribute(uvs, 2));
|
|
19
|
+
geometry.setIndex(new T.BufferAttribute(indices, 1));
|
|
20
|
+
return geometry;
|
|
21
|
+
}
|
|
22
|
+
/** The model's picture uses its own coordinates, with v upward. A texture loader flips a picture, so this puts it back. */
|
|
23
|
+
export function craftPicture(texture) {
|
|
24
|
+
texture.flipY = false;
|
|
25
|
+
texture.needsUpdate = true;
|
|
26
|
+
}
|
|
27
|
+
/** The picture lit by the same sun direction as every other body. The extra uniforms are the ones the body page and the painter write on every material. */
|
|
28
|
+
export function craftMaterial(T, ambient) {
|
|
29
|
+
return new T.ShaderMaterial({
|
|
30
|
+
side: 2,
|
|
31
|
+
vertexShader: /* glsl */ `
|
|
32
|
+
varying vec2 vUv;
|
|
33
|
+
varying vec3 vN;
|
|
34
|
+
void main() {
|
|
35
|
+
vUv = uv;
|
|
36
|
+
vN = normalize(normalMatrix * normal);
|
|
37
|
+
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);
|
|
38
|
+
}`,
|
|
39
|
+
fragmentShader: /* glsl */ `
|
|
40
|
+
precision highp float;
|
|
41
|
+
uniform vec3 uLight;
|
|
42
|
+
uniform float uAmbient;
|
|
43
|
+
uniform sampler2D uMap;
|
|
44
|
+
varying vec2 vUv;
|
|
45
|
+
varying vec3 vN;
|
|
46
|
+
void main() {
|
|
47
|
+
float shade = max(0.0, dot(normalize(vN), normalize(uLight)));
|
|
48
|
+
vec3 colour = texture2D(uMap, vUv).rgb;
|
|
49
|
+
gl_FragColor = vec4(colour * (shade * (1.0 - uAmbient) + uAmbient), 1.0);
|
|
50
|
+
}`,
|
|
51
|
+
uniforms: {
|
|
52
|
+
uMap: { value: null },
|
|
53
|
+
uLight: { value: new T.Vector3(1, 0, 0) },
|
|
54
|
+
uAmbient: { value: ambient },
|
|
55
|
+
uWrap: { value: 0 },
|
|
56
|
+
uRimBase: { value: 0 },
|
|
57
|
+
uScale: { value: 1 },
|
|
58
|
+
uRingN: { value: new T.Vector3(0, 1, 0) },
|
|
59
|
+
uOccN: { value: 0 },
|
|
60
|
+
uOcc: { value: new Float32Array(24) },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
package/dist/scene/glsl.js
CHANGED
|
@@ -170,7 +170,9 @@ ${world ? ` for (int i = 0; i < 6; i++) {
|
|
|
170
170
|
vec3 alb = pow(s.rgb, vec3(2.2));
|
|
171
171
|
vec3 lit = alb * (uAmbient + (1.0 - uAmbient) * diff * 1.18);
|
|
172
172
|
float rim = pow(1.0 - mu, uAtmosPow);
|
|
173
|
-
|
|
173
|
+
// the extra haze stops at the terminator: the old +0.35 stayed bright a little way onto the night side and drew a lighter strip beside the line
|
|
174
|
+
float dayRim = clamp(dg * 1.6 + 0.35, 0.0, 1.0) * smoothstep(-0.02, 0.08, dg);
|
|
175
|
+
lit += pow(uAtmos, vec3(2.2)) * rim * (uRimBase + (1.0 - uRimBase) * dayRim);
|
|
174
176
|
lit *= mix(1.0, pow(mu, 0.45), uLimb);
|
|
175
177
|
gl_FragColor = vec4(pow(lit, vec3(1.0 / 2.2)), 1.0);
|
|
176
178
|
}`;
|
package/dist/scene/look.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BodyId } from "../facts.ts";
|
|
2
|
+
import type { CraftMesh } from "./craft.ts";
|
|
2
3
|
import type { ShapeTable } from "./shape.ts";
|
|
3
4
|
export { shapeRadii, type ShapeTable } from "./shape.ts";
|
|
4
5
|
/**
|
|
@@ -15,6 +16,7 @@ export { shapeRadii, type ShapeTable } from "./shape.ts";
|
|
|
15
16
|
*/
|
|
16
17
|
export interface Atmosphere {
|
|
17
18
|
colour: readonly [number, number, number];
|
|
19
|
+
/** How much of `colour` the limb adds, from 0 to 1. The shader draws `colour` times this. */
|
|
18
20
|
strength: number;
|
|
19
21
|
/** How thin the rim is: higher is thinner. Default 3. */
|
|
20
22
|
power?: number;
|
|
@@ -105,6 +107,10 @@ export interface BodyLook {
|
|
|
105
107
|
* ellipsoid of `axesKm`. Until it arrives the ellipsoid is drawn.
|
|
106
108
|
*/
|
|
107
109
|
shape?: () => Promise<ShapeTable>;
|
|
110
|
+
/**
|
|
111
|
+
* A body drawn as a published mesh with that mesh's own picture on its faces (a chunk of its own). Not a map wrapped on a globe. Until it arrives, the body's shader is drawn.
|
|
112
|
+
*/
|
|
113
|
+
craft?: () => Promise<CraftMesh>;
|
|
108
114
|
/**
|
|
109
115
|
* An estimated rock shares one surface shader. These uniforms are that moon's own: a seed so the craters differ, and the dark and light colours of its albedo class.
|
|
110
116
|
* Only a look whose `surface` reads `uRockSeed`, `uRockDark` and `uRockLight` sets this.
|
|
@@ -136,6 +142,20 @@ export declare function detailOf(look: BodyLook): {
|
|
|
136
142
|
amount: number;
|
|
137
143
|
stretch: number;
|
|
138
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* The haze colour a body is drawn with: its atmosphere colour at `strength`, or black when it has none.
|
|
147
|
+
*
|
|
148
|
+
* @param atmosphere - The body's atmosphere, if it has one.
|
|
149
|
+
* @returns The colour the limb adds, each channel from 0 to 1.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { atmosphereTint } from "@johnmorrisdotca/wakusei-planets/look";
|
|
154
|
+
*
|
|
155
|
+
* console.log(atmosphereTint({ colour: [0.6, 0.7, 0.9], strength: 0.12 }));
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare function atmosphereTint(atmosphere: Atmosphere | undefined): [number, number, number];
|
|
139
159
|
/**
|
|
140
160
|
* Teach the package how to draw a body in three.js. Each body's entry point (`@johnmorrisdotca/wakusei-planets/jupiter`) calls this once as it loads; call it yourself to add or replace a look.
|
|
141
161
|
*
|
package/dist/scene/look.js
CHANGED
|
@@ -30,6 +30,25 @@ export function detailOf(look) {
|
|
|
30
30
|
const own = SMOOTH[look.id];
|
|
31
31
|
return { amount: look.detail?.amount ?? own?.amount ?? 0.32, stretch: look.detail?.stretch ?? own?.stretch ?? 1 };
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* The haze colour a body is drawn with: its atmosphere colour at `strength`, or black when it has none.
|
|
35
|
+
*
|
|
36
|
+
* @param atmosphere - The body's atmosphere, if it has one.
|
|
37
|
+
* @returns The colour the limb adds, each channel from 0 to 1.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { atmosphereTint } from "@johnmorrisdotca/wakusei-planets/look";
|
|
42
|
+
*
|
|
43
|
+
* console.log(atmosphereTint({ colour: [0.6, 0.7, 0.9], strength: 0.12 }));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function atmosphereTint(atmosphere) {
|
|
47
|
+
if (atmosphere === undefined)
|
|
48
|
+
return [0, 0, 0];
|
|
49
|
+
const strength = atmosphere.strength;
|
|
50
|
+
return [atmosphere.colour[0] * strength, atmosphere.colour[1] * strength, atmosphere.colour[2] * strength];
|
|
51
|
+
}
|
|
33
52
|
/**
|
|
34
53
|
* Teach the package how to draw a body in three.js. Each body's entry point (`@johnmorrisdotca/wakusei-planets/jupiter`) calls this once as it loads; call it yourself to add or replace a look.
|
|
35
54
|
*
|
|
@@ -177,3 +177,13 @@ export declare function setBodyLabelFontUrl(url: string | URL): void;
|
|
|
177
177
|
* @param squeeze - The uniforms a body drawn round shares with its name (see `round.ts`), so the name is squeezed with the globe. Left out, the name is not squeezed.
|
|
178
178
|
*/
|
|
179
179
|
export declare function createNameLabel(T: ThreeParts, text: string, options: NameLabelOptions, emissive: boolean, onReady: () => void, colour?: string, squeeze?: RoundUniforms): NameLabel;
|
|
180
|
+
/**
|
|
181
|
+
* The turn about the pole, in radians, that keeps a whole name on the side facing the camera. Zero when it is already clear of the limb. The name that faces the camera best is the one that moves,
|
|
182
|
+
* and only as far as its corners need, so a name that sits on the front still turns with the body. `camera` is in the shared label's frame (longitude 0 along +x, east towards -z).
|
|
183
|
+
*/
|
|
184
|
+
export declare function nameClearYaw(x: number, y: number, z: number, latitude: number, height: number, spans: readonly {
|
|
185
|
+
centre: number;
|
|
186
|
+
width: number;
|
|
187
|
+
}[]): number;
|
|
188
|
+
/** How far the highest point of a body's mesh is from its centre, in the mesh's own units (1 for a plain sphere): the radius of the smallest shell that clears the whole surface. */
|
|
189
|
+
export declare function shapeReach(geometry: THREE.BufferGeometry): number;
|
package/dist/scene/name-label.js
CHANGED
|
@@ -226,6 +226,7 @@ export function createNameLabel(T, text, options, emissive, onReady, colour, squ
|
|
|
226
226
|
let disposed = false;
|
|
227
227
|
let ready = false;
|
|
228
228
|
const light = new T.Vector3(0, 0, 1);
|
|
229
|
+
const eye = new T.Vector3();
|
|
229
230
|
const able = hasLabelParts(T) && canDraw();
|
|
230
231
|
if (!able && !warned && canDraw()) {
|
|
231
232
|
warned = true;
|
|
@@ -266,7 +267,22 @@ export function createNameLabel(T, text, options, emissive, onReady, colour, squ
|
|
|
266
267
|
u.uLight.value.copy(light);
|
|
267
268
|
u.uOpacity.value = m.opacity;
|
|
268
269
|
}
|
|
269
|
-
|
|
270
|
+
const changed = label.update((camera ?? FAR_EYE), radiusPx);
|
|
271
|
+
// a name that turns with the body runs off the limb and the planet cuts the letters: slide it, only as far as it needs, so the whole word stays on the near side
|
|
272
|
+
if (wanted.options.facing || camera === undefined)
|
|
273
|
+
return changed;
|
|
274
|
+
const mesh = label.object;
|
|
275
|
+
const parent = mesh.parent;
|
|
276
|
+
if (parent === null)
|
|
277
|
+
return changed;
|
|
278
|
+
camera.getWorldPosition(eye);
|
|
279
|
+
parent.updateWorldMatrix(true, false);
|
|
280
|
+
parent.worldToLocal(eye);
|
|
281
|
+
const yaw = nameClearYaw(eye.x, eye.y, eye.z, label.layout.latitude, label.layout.height, label.layout.spans);
|
|
282
|
+
if (Math.abs(mesh.rotation.y - yaw) <= 1e-4)
|
|
283
|
+
return changed;
|
|
284
|
+
mesh.rotation.y = yaw;
|
|
285
|
+
return true;
|
|
270
286
|
},
|
|
271
287
|
set(nextText, next) {
|
|
272
288
|
wanted = { text: nextText, options: shared(next) };
|
|
@@ -298,3 +314,79 @@ export function createNameLabel(T, text, options, emissive, onReady, colour, squ
|
|
|
298
314
|
function withoutUndefined(value) {
|
|
299
315
|
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
|
|
300
316
|
}
|
|
317
|
+
/** How far inside the limb a letter must stay, as a dot with the direction to the camera: about 56 degrees from the centre of the disc, so a letter is read face-on and not shaved off at the edge. */
|
|
318
|
+
const NAME_CLEAR = 0.55;
|
|
319
|
+
const pointOnBand = (latitude, longitude) => {
|
|
320
|
+
const lat = (latitude * Math.PI) / 180;
|
|
321
|
+
const lon = (longitude * Math.PI) / 180;
|
|
322
|
+
const ring = Math.cos(lat);
|
|
323
|
+
return [ring * Math.cos(lon), Math.sin(lat), -ring * Math.sin(lon)];
|
|
324
|
+
};
|
|
325
|
+
const turnedAboutPole = (point, yaw) => {
|
|
326
|
+
const c = Math.cos(yaw);
|
|
327
|
+
const s = Math.sin(yaw);
|
|
328
|
+
return [point[0] * c + point[2] * s, point[1], -point[0] * s + point[2] * c];
|
|
329
|
+
};
|
|
330
|
+
/** The smallest dot a name's four corners make with the camera, after a turn `yaw` about the pole. */
|
|
331
|
+
const nameCornerDot = (camera, latitude, centre, halfWidth, halfHeight, yaw) => {
|
|
332
|
+
let least = Infinity;
|
|
333
|
+
for (const longitude of [centre - halfWidth, centre + halfWidth]) {
|
|
334
|
+
for (const band of [latitude - halfHeight, latitude + halfHeight]) {
|
|
335
|
+
const point = turnedAboutPole(pointOnBand(band, longitude), yaw);
|
|
336
|
+
least = Math.min(least, point[0] * camera[0] + point[1] * camera[1] + point[2] * camera[2]);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return least;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* The turn about the pole, in radians, that keeps a whole name on the side facing the camera. Zero when it is already clear of the limb. The name that faces the camera best is the one that moves,
|
|
343
|
+
* and only as far as its corners need, so a name that sits on the front still turns with the body. `camera` is in the shared label's frame (longitude 0 along +x, east towards -z).
|
|
344
|
+
*/
|
|
345
|
+
export function nameClearYaw(x, y, z, latitude, height, spans) {
|
|
346
|
+
const length = Math.hypot(x, y, z);
|
|
347
|
+
if (length < 1e-8 || spans.length === 0)
|
|
348
|
+
return 0;
|
|
349
|
+
const camera = [x / length, y / length, z / length];
|
|
350
|
+
let span = spans[0];
|
|
351
|
+
let facingDot = -Infinity;
|
|
352
|
+
for (const one of spans) {
|
|
353
|
+
const point = pointOnBand(latitude, one.centre);
|
|
354
|
+
const dot = point[0] * camera[0] + point[1] * camera[1] + point[2] * camera[2];
|
|
355
|
+
if (dot > facingDot) {
|
|
356
|
+
facingDot = dot;
|
|
357
|
+
span = one;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const halfWidth = span.width / 2;
|
|
361
|
+
const halfHeight = height / 2;
|
|
362
|
+
if (nameCornerDot(camera, latitude, span.centre, halfWidth, halfHeight, 0) >= NAME_CLEAR)
|
|
363
|
+
return 0;
|
|
364
|
+
const cameraLongitude = Math.atan2(-camera[2], camera[0]);
|
|
365
|
+
const toward = cameraLongitude - (span.centre * Math.PI) / 180;
|
|
366
|
+
const facing = Math.atan2(Math.sin(toward), Math.cos(toward));
|
|
367
|
+
if (nameCornerDot(camera, latitude, span.centre, halfWidth, halfHeight, facing) < NAME_CLEAR)
|
|
368
|
+
return facing;
|
|
369
|
+
let near = 0;
|
|
370
|
+
let far = 1;
|
|
371
|
+
for (let step = 0; step < 16; step += 1) {
|
|
372
|
+
const mid = (near + far) / 2;
|
|
373
|
+
if (nameCornerDot(camera, latitude, span.centre, halfWidth, halfHeight, mid * facing) >= NAME_CLEAR)
|
|
374
|
+
far = mid;
|
|
375
|
+
else
|
|
376
|
+
near = mid;
|
|
377
|
+
}
|
|
378
|
+
return far * facing;
|
|
379
|
+
}
|
|
380
|
+
const reaches = new WeakMap();
|
|
381
|
+
/** How far the highest point of a body's mesh is from its centre, in the mesh's own units (1 for a plain sphere): the radius of the smallest shell that clears the whole surface. */
|
|
382
|
+
export function shapeReach(geometry) {
|
|
383
|
+
let reach = reaches.get(geometry);
|
|
384
|
+
if (reach === undefined) {
|
|
385
|
+
const at = geometry.getAttribute("position");
|
|
386
|
+
reach = 1;
|
|
387
|
+
for (let i = 0; i < at.count; i += 1)
|
|
388
|
+
reach = Math.max(reach, Math.hypot(at.getX(i), at.getY(i), at.getZ(i)));
|
|
389
|
+
reaches.set(geometry, reach);
|
|
390
|
+
}
|
|
391
|
+
return reach;
|
|
392
|
+
}
|
package/dist/scene/painter.d.ts
CHANGED
|
@@ -162,12 +162,13 @@ export interface Painting {
|
|
|
162
162
|
readonly tiles?: DetailStats;
|
|
163
163
|
/** Write the body's name on its globe, change how, or take it off (`null`). The name is drawn when the font is in, and `context.invalidate` is called then. */
|
|
164
164
|
setLabel(label: PaintLabel | null): void;
|
|
165
|
-
/** The name on the globe now: whether one is drawn (made and big enough on the screen at the last `update`), the text, and the group's turn about the pole in radians (for `facing`). */
|
|
165
|
+
/** The name on the globe now: whether one is drawn (made and big enough on the screen at the last `update`), the text, and the group's turn about the pole in radians (for `facing`), and `shell`, the radius of the shell the name is written on in the mesh's units (1 on a smooth globe, more on a lumpy moon). */
|
|
166
166
|
readonly label: {
|
|
167
167
|
shown: boolean;
|
|
168
168
|
text: string;
|
|
169
169
|
turn: number;
|
|
170
170
|
look: string;
|
|
171
|
+
shell: number;
|
|
171
172
|
} | null;
|
|
172
173
|
dispose(): void;
|
|
173
174
|
}
|