@johnmorrisdotca/wakusei-planets 0.74.2 → 0.75.1
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 +28 -1
- package/NOTICE.md +4 -3
- package/README.md +7 -7
- 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/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/discovery.js +30 -0
- package/dist/data/estimated-moons.js +354 -354
- 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/element.d.ts +1 -1
- package/dist/element.js +19 -2
- package/dist/facts.d.ts +1 -1
- package/dist/facts.js +4 -1
- package/dist/flat/bodies.d.ts +11 -10
- package/dist/flat/bodies.js +62 -28
- package/dist/flat/element.d.ts +55 -16
- package/dist/flat/element.js +746 -86
- package/dist/flat/index.d.ts +4 -2
- package/dist/flat/index.js +5 -3
- package/dist/flat/look.d.ts +206 -0
- package/dist/flat/look.js +305 -0
- package/dist/flat/marks.d.ts +122 -0
- package/dist/flat/marks.js +60 -0
- package/dist/flat/scene.d.ts +119 -2
- package/dist/flat/scene.js +130 -2
- package/dist/flat/words.d.ts +16 -0
- package/dist/flat/words.js +74 -1
- 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/portrait/model.js +3 -3
- package/dist/scene/body.d.ts +1 -0
- package/dist/scene/body.js +8 -4
- package/dist/scene/glsl.js +3 -1
- package/dist/scene/look.d.ts +15 -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 +8 -4
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +15 -1
- package/dist/space/element.js +23 -1
- 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) {
|
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,7 @@ 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
6
|
import { shapeGeometry } from "./shape.js";
|
|
7
7
|
import { createDetail } from "./detail.js";
|
|
8
8
|
import { fallbackLook } from "./fallback.js";
|
|
@@ -10,7 +10,7 @@ import { writeBasis } from "./basis.js";
|
|
|
10
10
|
import { interiorOf } from "../interior.js";
|
|
11
11
|
import { loadImage } from "./textures.js";
|
|
12
12
|
import { ringStrip } from "./rings.js";
|
|
13
|
-
import { createNameLabel } from "./name-label.js";
|
|
13
|
+
import { createNameLabel, shapeReach } from "./name-label.js";
|
|
14
14
|
export { fallbackLook } from "./fallback.js";
|
|
15
15
|
/** 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
16
|
export function makeBodyMaterial(T, look, painted) {
|
|
@@ -35,7 +35,7 @@ export function makeBodyMaterial(T, look, painted) {
|
|
|
35
35
|
uAmbient: { value: look.ambient ?? 0.04 },
|
|
36
36
|
uLimb: { value: look.limb ?? 0 },
|
|
37
37
|
uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
|
|
38
|
-
uAtmos: { value: new T.Vector3(...(a
|
|
38
|
+
uAtmos: { value: new T.Vector3(...atmosphereTint(a)) },
|
|
39
39
|
uAtmosPow: { value: a?.power ?? 3 },
|
|
40
40
|
uRimBase: { value: 0.12 },
|
|
41
41
|
uEmissive: { value: look.emissive === true ? 1 : 0 },
|
|
@@ -419,6 +419,10 @@ export function createBodyItem(options) {
|
|
|
419
419
|
if (label === undefined) {
|
|
420
420
|
label = createNameLabel(T, state.label.text, state.label, look.emissive === true, () => options.redraw(), facts.colour);
|
|
421
421
|
mesh.add(label.object);
|
|
422
|
+
// 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
|
|
423
|
+
const reach = shapeReach(geometry);
|
|
424
|
+
if (reach > 1.002)
|
|
425
|
+
label.object.scale.setScalar(reach);
|
|
422
426
|
}
|
|
423
427
|
else {
|
|
424
428
|
label.set(state.label.text, state.label);
|
|
@@ -499,7 +503,7 @@ export function createBodyItem(options) {
|
|
|
499
503
|
},
|
|
500
504
|
get label() {
|
|
501
505
|
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 };
|
|
506
|
+
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
507
|
},
|
|
504
508
|
resize(w, h) {
|
|
505
509
|
viewWidth = w;
|
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
|
@@ -15,6 +15,7 @@ export { shapeRadii, type ShapeTable } from "./shape.ts";
|
|
|
15
15
|
*/
|
|
16
16
|
export interface Atmosphere {
|
|
17
17
|
colour: readonly [number, number, number];
|
|
18
|
+
/** How much of `colour` the limb adds, from 0 to 1. The shader draws `colour` times this. */
|
|
18
19
|
strength: number;
|
|
19
20
|
/** How thin the rim is: higher is thinner. Default 3. */
|
|
20
21
|
power?: number;
|
|
@@ -136,6 +137,20 @@ export declare function detailOf(look: BodyLook): {
|
|
|
136
137
|
amount: number;
|
|
137
138
|
stretch: number;
|
|
138
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* The haze colour a body is drawn with: its atmosphere colour at `strength`, or black when it has none.
|
|
142
|
+
*
|
|
143
|
+
* @param atmosphere - The body's atmosphere, if it has one.
|
|
144
|
+
* @returns The colour the limb adds, each channel from 0 to 1.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* import { atmosphereTint } from "@johnmorrisdotca/wakusei-planets/look";
|
|
149
|
+
*
|
|
150
|
+
* console.log(atmosphereTint({ colour: [0.6, 0.7, 0.9], strength: 0.12 }));
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function atmosphereTint(atmosphere: Atmosphere | undefined): [number, number, number];
|
|
139
154
|
/**
|
|
140
155
|
* 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
156
|
*
|
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
|
}
|
package/dist/scene/painter.js
CHANGED
|
@@ -9,12 +9,12 @@ import { cross } from "../vec.js";
|
|
|
9
9
|
import { bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, PAINTED_SURFACE_WINDOWED, RING_FRAGMENT_WORLD, RING_VERTEX_WORLD, VERTEX_WORLD } from "./glsl.js";
|
|
10
10
|
import { fallbackLook } from "./fallback.js";
|
|
11
11
|
import { createDetail } from "./detail.js";
|
|
12
|
-
import { detailOf, lookOf } from "./look.js";
|
|
12
|
+
import { atmosphereTint, detailOf, lookOf } from "./look.js";
|
|
13
13
|
import { shapeGeometry } from "./shape.js";
|
|
14
14
|
import { seenRegion } from "./tiles.js";
|
|
15
15
|
import { moonOffset, orientation } from "./orient.js";
|
|
16
16
|
import { ringStrip } from "./rings.js";
|
|
17
|
-
import { createNameLabel, nameLabelText } from "./name-label.js";
|
|
17
|
+
import { createNameLabel, nameLabelText, shapeReach } from "./name-label.js";
|
|
18
18
|
import { roundShape } from "./round.js";
|
|
19
19
|
let pictureLoads = 0;
|
|
20
20
|
/**
|
|
@@ -154,7 +154,7 @@ function paint(T, id, context, bases, hold) {
|
|
|
154
154
|
uAmbient: { value: look.ambient ?? 0.04 },
|
|
155
155
|
uLimb: { value: look.limb ?? 0 },
|
|
156
156
|
uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
|
|
157
|
-
uAtmos: { value: new T.Vector3(...(a
|
|
157
|
+
uAtmos: { value: new T.Vector3(...atmosphereTint(a)) },
|
|
158
158
|
uAtmosPow: { value: a?.power ?? 3 },
|
|
159
159
|
uRimBase: { value: 0.12 },
|
|
160
160
|
uEmissive: { value: look.emissive === true ? 1 : 0 },
|
|
@@ -411,7 +411,7 @@ function paint(T, id, context, bases, hold) {
|
|
|
411
411
|
let labelText = "";
|
|
412
412
|
let labelShown = false;
|
|
413
413
|
// what `label` reports: one object, written at each draw (it is read for every body at every frame)
|
|
414
|
-
const labelReport = { shown: false, text: "", turn: 0, look: "" };
|
|
414
|
+
const labelReport = { shown: false, text: "", turn: 0, look: "", shell: 1 };
|
|
415
415
|
const setLabel = (next) => {
|
|
416
416
|
if (next === null || next === undefined || gone) {
|
|
417
417
|
if (label !== undefined) {
|
|
@@ -502,6 +502,10 @@ function paint(T, id, context, bases, hold) {
|
|
|
502
502
|
}
|
|
503
503
|
keepSized(info.radiusPx);
|
|
504
504
|
if (label !== undefined) {
|
|
505
|
+
// a lumpy shape stands out past the sphere the name is written on: the shell clears its highest point
|
|
506
|
+
labelReport.shell = shapeReach(mesh.geometry);
|
|
507
|
+
if (labelReport.shell > 1.002 || label.object.scale.x !== 1)
|
|
508
|
+
label.object.scale.setScalar(Math.max(1, labelReport.shell));
|
|
505
509
|
label.update(info.view?.camera, info.radiusPx, info.toSun);
|
|
506
510
|
const inner = label.object.children[0];
|
|
507
511
|
labelShown = inner !== undefined && inner.visible;
|
package/dist/scene/textures.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type BodyMapSource } from "../door/map.ts";
|
|
|
11
11
|
* console.log(TEXTURE_BASE);
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.
|
|
14
|
+
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.75.1/dist/textures/";
|
|
15
15
|
/**
|
|
16
16
|
* Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
|
|
17
17
|
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
@@ -23,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
|
|
|
23
23
|
* console.log(TEXTURE_FAR_BASE);
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.
|
|
26
|
+
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.75.1/textures/";
|
|
27
27
|
/**
|
|
28
28
|
* Where the finer map tiles are by default: the demo site's `tiles/` folder (GitHub Pages sends `access-control-allow-origin: *`). The tiles are made by `scripts/make-body-tiles.py` and are in no package and no repository:
|
|
29
29
|
* a page that serves its own gives the folder in the `tiles` attribute, and `tiles="off"` turns them off. A page that sets `texture-base` (it serves its own pictures) has none unless it says where they are.
|
package/dist/space/element.d.ts
CHANGED
|
@@ -606,6 +606,20 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
606
606
|
}, final?: boolean, reason?: string): void;
|
|
607
607
|
/** The body the camera looks at: any body the view places, by name in any case (`earth`, `sun`, `moon`, `mercury` to `neptune`, `pluto`, and the moons of the planets such as `titan`). At zoom 1 it fills the view; the yaw and tilt turn the camera round it. Setting it moves the camera there at once and keeps the zoom; `goTo` glides and brings the body into view. */
|
|
608
608
|
get body(): BodyId;
|
|
609
|
+
/**
|
|
610
|
+
* The body the camera is at, which is `body` unless `turnTo` has turned the view to another body from where the camera stands: then `body` is the body looked at and `at` is the one the camera is still at, so a page can tell "looking at" from "at".
|
|
611
|
+
* It follows `body` the moment the camera goes anywhere (`goTo`, setting `body`, a hop).
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```ts no-run
|
|
615
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
616
|
+
*
|
|
617
|
+
* const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
|
|
618
|
+
* space.turnTo("mars", { smooth: false });
|
|
619
|
+
* console.log(space.body, space.at);
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
get at(): BodyId;
|
|
609
623
|
set body(name: BodyId | string);
|
|
610
624
|
/** What the hopper can do from where it is: the body at the middle, and the bodies the previous and next hop lead to. */
|
|
611
625
|
get hopper(): {
|
|
@@ -651,7 +665,7 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
651
665
|
/**
|
|
652
666
|
* Turn the camera where it stands until a body is in the picture, by the least turn: no move of the camera's place, only the way it looks. A body is in the picture when its middle is inside the picture less `margin` of
|
|
653
667
|
* each side (the left and right margins are `margin` of the width, the top and bottom `margin` of the height; 0.15 by default, 0 to 0.45). One already so is left alone and the answer is `false`, as it is for an id the
|
|
654
|
-
* view does not know, the body already looked at, and a view that is riding. The body becomes the one looked at: the camera stays at its place and looks at it, from as far
|
|
668
|
+
* view does not know, the body already looked at, and a view that is riding (a camera beside the Moon in a ride is not turned: ride off first). The body becomes the one looked at (`body`) while `at` still names the body the camera stands at: the camera stays at its place and looks at it, from as far
|
|
655
669
|
* as it stands (the zoom is worked out from that distance, inside the controls' limits; a body so far that the zoom's limit would move the camera is not turned to). It glides the way a move does, or at once with
|
|
656
670
|
* `smooth: false` or for a reader who prefers reduced motion; nothing is drawn at rest and one draw more at most ends it.
|
|
657
671
|
*
|
package/dist/space/element.js
CHANGED
|
@@ -206,6 +206,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
206
206
|
#hands;
|
|
207
207
|
#markLayer;
|
|
208
208
|
#markList;
|
|
209
|
+
/** The body the camera stands at while `turnTo` has turned the view to another: the body looked at is `to`, the camera is still at `at`. Let go when the camera goes to a body. */
|
|
210
|
+
#turned = null;
|
|
209
211
|
#markLoading;
|
|
210
212
|
#markHeard;
|
|
211
213
|
#placeGlide = 0;
|
|
@@ -1716,6 +1718,22 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1716
1718
|
get body() {
|
|
1717
1719
|
return this.#model.focus;
|
|
1718
1720
|
}
|
|
1721
|
+
/**
|
|
1722
|
+
* The body the camera is at, which is `body` unless `turnTo` has turned the view to another body from where the camera stands: then `body` is the body looked at and `at` is the one the camera is still at, so a page can tell "looking at" from "at".
|
|
1723
|
+
* It follows `body` the moment the camera goes anywhere (`goTo`, setting `body`, a hop).
|
|
1724
|
+
*
|
|
1725
|
+
* @example
|
|
1726
|
+
* ```ts no-run
|
|
1727
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
1728
|
+
*
|
|
1729
|
+
* const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
|
|
1730
|
+
* space.turnTo("mars", { smooth: false });
|
|
1731
|
+
* console.log(space.body, space.at);
|
|
1732
|
+
* ```
|
|
1733
|
+
*/
|
|
1734
|
+
get at() {
|
|
1735
|
+
return this.#turned !== null && this.#turned.to === this.#model.focus ? this.#turned.at : this.#model.focus;
|
|
1736
|
+
}
|
|
1719
1737
|
set body(name) {
|
|
1720
1738
|
const id = readBody(name);
|
|
1721
1739
|
if (!id)
|
|
@@ -1725,6 +1743,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1725
1743
|
/** Move the camera to `id` (not yet drawn) and tell the page. */
|
|
1726
1744
|
#centre(id) {
|
|
1727
1745
|
const was = this.#model.focus;
|
|
1746
|
+
this.#turned = null;
|
|
1728
1747
|
this.#model.focus = id;
|
|
1729
1748
|
this.#gate?.request();
|
|
1730
1749
|
if (was !== id)
|
|
@@ -1786,6 +1805,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1786
1805
|
model.region = null;
|
|
1787
1806
|
this.#showRegion();
|
|
1788
1807
|
this.#selected = id;
|
|
1808
|
+
this.#turned = null;
|
|
1789
1809
|
this.#model.focus = id;
|
|
1790
1810
|
const zoom = options.zoom ?? 1;
|
|
1791
1811
|
// the side the camera comes from, as the controls' yaw and tilt: the element's own hands are set to it here, and a bar bound to the element (which holds the view's state) hears it in the event with the zoom
|
|
@@ -1809,7 +1829,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1809
1829
|
/**
|
|
1810
1830
|
* Turn the camera where it stands until a body is in the picture, by the least turn: no move of the camera's place, only the way it looks. A body is in the picture when its middle is inside the picture less `margin` of
|
|
1811
1831
|
* each side (the left and right margins are `margin` of the width, the top and bottom `margin` of the height; 0.15 by default, 0 to 0.45). One already so is left alone and the answer is `false`, as it is for an id the
|
|
1812
|
-
* view does not know, the body already looked at, and a view that is riding. The body becomes the one looked at: the camera stays at its place and looks at it, from as far
|
|
1832
|
+
* view does not know, the body already looked at, and a view that is riding (a camera beside the Moon in a ride is not turned: ride off first). The body becomes the one looked at (`body`) while `at` still names the body the camera stands at: the camera stays at its place and looks at it, from as far
|
|
1813
1833
|
* as it stands (the zoom is worked out from that distance, inside the controls' limits; a body so far that the zoom's limit would move the camera is not turned to). It glides the way a move does, or at once with
|
|
1814
1834
|
* `smooth: false` or for a reader who prefers reduced motion; nothing is drawn at rest and one draw more at most ends it.
|
|
1815
1835
|
*
|
|
@@ -1869,6 +1889,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1869
1889
|
model.region = null;
|
|
1870
1890
|
this.#showRegion();
|
|
1871
1891
|
this.#selected = id;
|
|
1892
|
+
// the camera stays at the body it stood at, or the one it was already turned from: the view looks at `id`
|
|
1893
|
+
this.#turned = { at: this.#turned !== null && this.#turned.to === model.focus ? this.#turned.at : model.focus, to: id };
|
|
1872
1894
|
model.focus = id;
|
|
1873
1895
|
if (this.#hands !== undefined && !this.hasAttribute("data-kazoku-bar"))
|
|
1874
1896
|
this.#hands.controller.set({ yaw, tilt, zoom }, true, "jump");
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.75.1";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The published package version. Snippets and texture addresses name it. test/version.test.ts keeps it equal to package.json.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.75.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.1",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|