@johnmorrisdotca/wakusei-planets 0.38.0 → 0.40.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 +13 -0
- package/NOTICE.md +2 -2
- package/README.md +4 -4
- package/dist/door/own.js +4 -2
- package/dist/embed.d.ts +4 -1
- package/dist/embed.js +21 -10
- package/dist/ground-track.d.ts +80 -0
- package/dist/ground-track.js +137 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/paint/trail.d.ts +80 -0
- package/dist/paint/trail.js +322 -0
- package/dist/picture-credits.d.ts +78 -0
- package/dist/picture-credits.js +120 -0
- package/dist/scene/painter.d.ts +11 -0
- package/dist/scene/painter.js +30 -2
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +23 -0
- package/dist/space/element.js +41 -0
- package/dist/space/paint-overlay.d.ts +11 -0
- package/dist/space/paint-overlay.js +84 -0
- package/dist/space/scene.d.ts +5 -0
- package/dist/space/scene.js +25 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
package/dist/space/element.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import { type Place } from "../places.ts";
|
|
|
17
17
|
import { type PlaceLayer } from "../place-marks.ts";
|
|
18
18
|
import { type EarthPlace, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
19
19
|
import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
|
|
20
|
+
import { type PaintSpec } from "../paint/trail.ts";
|
|
21
|
+
export type { PaintSpec };
|
|
20
22
|
export { setPlacesLoader } from "../scene/place-layer.ts";
|
|
21
23
|
export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS, type EarthPlace, type EarthPlaceKind, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
22
24
|
export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
|
|
@@ -279,6 +281,27 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
279
281
|
*/
|
|
280
282
|
get orbiters(): boolean;
|
|
281
283
|
set orbiters(value: boolean);
|
|
284
|
+
/**
|
|
285
|
+
* Paint one orbiter's path on the body it goes round. `id` is an orbiter such as `lro` or `mro`. `length` is how long the trail is kept, in simulated time (`1d` when left out, or `1w`, `1m`).
|
|
286
|
+
* `swath` is `track` (the point under the craft, the default) or `coverage` (where it is at least 10° above the horizon). Setting another craft clears the trail. `null` clears it.
|
|
287
|
+
* The trail is drawn only while time is moving, one upload a frame, and nothing at rest.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts no-run
|
|
291
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
292
|
+
*
|
|
293
|
+
* const paint = (space: WakuseiSpace): void => {
|
|
294
|
+
* space.paint = { id: "lro", length: "1d", swath: "track" };
|
|
295
|
+
* };
|
|
296
|
+
* console.log(typeof paint);
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
get paint(): PaintSpec | null;
|
|
300
|
+
set paint(value: PaintSpec | null);
|
|
301
|
+
/** Take the painted trail off the body. */
|
|
302
|
+
clearPaint(): void;
|
|
303
|
+
/** Texels the trail has painted. 0 after `clearPaint`, and again when the painted craft changes. */
|
|
304
|
+
get paintPixels(): number;
|
|
282
305
|
/**
|
|
283
306
|
* Show Starman and the Tesla Roadster (the attribute `roadster`; off by default): a small marked body where `/roadster` puts the car on the date shown, on its orbit line (about one trip round the Sun), with its name
|
|
284
307
|
* (`Starman`, `スターマン`) beside it, from the launch in 2018 to the end of 2035. Its path (a 20 kB table) is loaded the first time it is shown, and never when it is not. `stats.roadster` says what was drawn.
|
package/dist/space/element.js
CHANGED
|
@@ -28,6 +28,7 @@ import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-l
|
|
|
28
28
|
import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
|
|
29
29
|
import { cross, dot } from "../vec.js";
|
|
30
30
|
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
31
|
+
import { paintLengthOf, paintSwathOf } from "../paint/trail.js";
|
|
31
32
|
export { setPlacesLoader } from "../scene/place-layer.js";
|
|
32
33
|
export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "../scene/earth-places.js";
|
|
33
34
|
export { setThreeLoader, SPACE_BODIES };
|
|
@@ -775,6 +776,46 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
775
776
|
}
|
|
776
777
|
this.#gate?.request();
|
|
777
778
|
}
|
|
779
|
+
/**
|
|
780
|
+
* Paint one orbiter's path on the body it goes round. `id` is an orbiter such as `lro` or `mro`. `length` is how long the trail is kept, in simulated time (`1d` when left out, or `1w`, `1m`).
|
|
781
|
+
* `swath` is `track` (the point under the craft, the default) or `coverage` (where it is at least 10° above the horizon). Setting another craft clears the trail. `null` clears it.
|
|
782
|
+
* The trail is drawn only while time is moving, one upload a frame, and nothing at rest.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```ts no-run
|
|
786
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
787
|
+
*
|
|
788
|
+
* const paint = (space: WakuseiSpace): void => {
|
|
789
|
+
* space.paint = { id: "lro", length: "1d", swath: "track" };
|
|
790
|
+
* };
|
|
791
|
+
* console.log(typeof paint);
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
794
|
+
get paint() {
|
|
795
|
+
const spec = this.#model.paint;
|
|
796
|
+
return spec === null ? null : { id: spec.id, length: paintLengthOf(spec.length), swath: paintSwathOf(spec.swath) };
|
|
797
|
+
}
|
|
798
|
+
set paint(value) {
|
|
799
|
+
if (value === null) {
|
|
800
|
+
this.#model.paint = null;
|
|
801
|
+
this.#model.paintTrail.clear();
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
const next = { id: String(value.id), length: paintLengthOf(value.length), swath: paintSwathOf(value.swath) };
|
|
805
|
+
this.#model.paint = next;
|
|
806
|
+
this.#model.paintTrail.set(next);
|
|
807
|
+
this.orbiters = true;
|
|
808
|
+
}
|
|
809
|
+
this.#gate?.request();
|
|
810
|
+
}
|
|
811
|
+
/** Take the painted trail off the body. */
|
|
812
|
+
clearPaint() {
|
|
813
|
+
this.paint = null;
|
|
814
|
+
}
|
|
815
|
+
/** Texels the trail has painted. 0 after `clearPaint`, and again when the painted craft changes. */
|
|
816
|
+
get paintPixels() {
|
|
817
|
+
return this.#model.paintTrail.pixels;
|
|
818
|
+
}
|
|
778
819
|
#roadsterLoading = false;
|
|
779
820
|
/**
|
|
780
821
|
* Show Starman and the Tesla Roadster (the attribute `roadster`; off by default): a small marked body where `/roadster` puts the car on the date shown, on its orbit line (about one trip round the Sun), with its name
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
import type { ThreeParts } from "../scene/body.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The trail drawn on a body. `show` parents it to that body's oriented mesh. `hide` draws nothing and gives the picture's and the sphere's copies on the graphics card back, so a view with paint off
|
|
5
|
+
* holds none of it. `dispose` frees the geometry, the material and the texture for good.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createPaintOverlay(three: ThreeParts, data: Uint8Array): {
|
|
8
|
+
show(host: THREE.Object3D, nowMinute: number, spanMinutes: number, upload: boolean): void;
|
|
9
|
+
hide(): void;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PAINT_H, PAINT_W } from "../paint/trail.js";
|
|
2
|
+
const VERTEX = /* glsl */ `
|
|
3
|
+
varying vec3 vLocal;
|
|
4
|
+
void main() {
|
|
5
|
+
vLocal = normalize(position);
|
|
6
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
9
|
+
const FRAGMENT = /* glsl */ `
|
|
10
|
+
uniform sampler2D uMap;
|
|
11
|
+
uniform float uNow;
|
|
12
|
+
uniform float uSpan;
|
|
13
|
+
varying vec3 vLocal;
|
|
14
|
+
void main() {
|
|
15
|
+
float lat = asin(clamp(vLocal.y, -1.0, 1.0));
|
|
16
|
+
float lon = atan(vLocal.x, vLocal.z);
|
|
17
|
+
vec2 uv = vec2(lon / 6.2831853 + 0.5, 0.5 - lat / 3.14159265);
|
|
18
|
+
vec4 stamp = texture2D(uMap, uv);
|
|
19
|
+
float then = floor(stamp.r * 255.0 + 0.5) * 256.0 + floor(stamp.g * 255.0 + 0.5);
|
|
20
|
+
float age = uNow - then;
|
|
21
|
+
if (age < -32768.0) age += 65536.0;
|
|
22
|
+
if (age > 32768.0) age -= 65536.0;
|
|
23
|
+
float show = stamp.a * step(-1.0, age) * (1.0 - smoothstep(uSpan * 0.82, uSpan, max(age, 0.0)));
|
|
24
|
+
if (show < 0.04) discard;
|
|
25
|
+
gl_FragColor = vec4(1.0, 0.55, 0.12, clamp(show, 0.0, 0.9));
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
/**
|
|
29
|
+
* The trail drawn on a body. `show` parents it to that body's oriented mesh. `hide` draws nothing and gives the picture's and the sphere's copies on the graphics card back, so a view with paint off
|
|
30
|
+
* holds none of it. `dispose` frees the geometry, the material and the texture for good.
|
|
31
|
+
*/
|
|
32
|
+
export function createPaintOverlay(three, data) {
|
|
33
|
+
const texture = new three.DataTexture(data, PAINT_W, PAINT_H, three.RGBAFormat);
|
|
34
|
+
texture.flipY = false;
|
|
35
|
+
texture.magFilter = three.LinearFilter;
|
|
36
|
+
texture.minFilter = three.LinearFilter;
|
|
37
|
+
texture.generateMipmaps = false;
|
|
38
|
+
texture.colorSpace = three.NoColorSpace;
|
|
39
|
+
texture.needsUpdate = false;
|
|
40
|
+
const geometry = new three.SphereGeometry(1.004, 64, 32);
|
|
41
|
+
const material = new three.ShaderMaterial({
|
|
42
|
+
vertexShader: VERTEX,
|
|
43
|
+
fragmentShader: FRAGMENT,
|
|
44
|
+
transparent: true,
|
|
45
|
+
depthWrite: false,
|
|
46
|
+
uniforms: { uMap: { value: texture }, uNow: { value: 0 }, uSpan: { value: 1440 } },
|
|
47
|
+
});
|
|
48
|
+
const mesh = new three.Mesh(geometry, material);
|
|
49
|
+
mesh.name = "ground-track";
|
|
50
|
+
mesh.frustumCulled = false;
|
|
51
|
+
mesh.renderOrder = 3;
|
|
52
|
+
mesh.visible = false;
|
|
53
|
+
/** Whether the texture or the sphere may be on the graphics card. */
|
|
54
|
+
let held = false;
|
|
55
|
+
return {
|
|
56
|
+
show(host, nowMinute, spanMinutes, upload) {
|
|
57
|
+
if (mesh.parent !== host)
|
|
58
|
+
host.add(mesh);
|
|
59
|
+
mesh.visible = true;
|
|
60
|
+
if (!held) {
|
|
61
|
+
held = true;
|
|
62
|
+
texture.needsUpdate = true;
|
|
63
|
+
}
|
|
64
|
+
material.uniforms.uNow.value = nowMinute;
|
|
65
|
+
material.uniforms.uSpan.value = spanMinutes;
|
|
66
|
+
if (upload)
|
|
67
|
+
texture.needsUpdate = true;
|
|
68
|
+
},
|
|
69
|
+
hide() {
|
|
70
|
+
mesh.visible = false;
|
|
71
|
+
if (held) {
|
|
72
|
+
held = false;
|
|
73
|
+
texture.dispose();
|
|
74
|
+
geometry.dispose();
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
dispose() {
|
|
78
|
+
mesh.parent?.remove(mesh);
|
|
79
|
+
geometry.dispose();
|
|
80
|
+
material.dispose();
|
|
81
|
+
texture.dispose();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { type Vec3 } from "../vec.ts";
|
|
|
11
11
|
import { type OrbitArrow } from "./arrows.ts";
|
|
12
12
|
import type { SightInput } from "./sight.ts";
|
|
13
13
|
import { type SpaceFrame, type SpaceVec3 } from "./frame.ts";
|
|
14
|
+
import { type PaintSpec, type PaintTrail } from "../paint/trail.ts";
|
|
14
15
|
import { type RideLook } from "./ride.ts";
|
|
15
16
|
import { type ScaleMode } from "./scale.ts";
|
|
16
17
|
import { type SunRegion } from "./regions.ts";
|
|
@@ -218,6 +219,10 @@ export interface SpaceModel {
|
|
|
218
219
|
lines: number;
|
|
219
220
|
track: number;
|
|
220
221
|
};
|
|
222
|
+
/** The craft whose ground track is painted on its body, or null. */
|
|
223
|
+
paint: PaintSpec | null;
|
|
224
|
+
/** The trail buffer the element and the scene share. */
|
|
225
|
+
paintTrail: PaintTrail;
|
|
221
226
|
/** Show Starman and the Roadster: a small marked body on its orbit line, named. Off by default; its path is loaded when it is first shown. */
|
|
222
227
|
roadster: boolean;
|
|
223
228
|
roadsterPath: RoadsterPath | null;
|
package/dist/space/scene.js
CHANGED
|
@@ -14,6 +14,8 @@ import { besideMoon } from "./beside.js";
|
|
|
14
14
|
import { coveredBy } from "./covered.js";
|
|
15
15
|
import { spinAxis } from "./spin.js";
|
|
16
16
|
import { createTrack, eclipticToScene, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
17
|
+
import { createPaintOverlay } from "./paint-overlay.js";
|
|
18
|
+
import { createPaintTrail, groundUnder, paintMinute } from "../paint/trail.js";
|
|
17
19
|
import { BALL_FRAGMENT, VERTEX } from "../scene/glsl.js";
|
|
18
20
|
import { ridePose } from "./ride.js";
|
|
19
21
|
import { moonDistance, orbitLine, placeAround, placeBodies, placeMoon, radiusIn } from "./scale.js";
|
|
@@ -98,6 +100,8 @@ export const newSpaceModel = () => ({
|
|
|
98
100
|
orbiterLines: "all",
|
|
99
101
|
orbiterTrack: false,
|
|
100
102
|
orbitersDrawn: { count: 0, status: {}, dim: [], lines: 0, track: 0 },
|
|
103
|
+
paint: null,
|
|
104
|
+
paintTrail: createPaintTrail(),
|
|
101
105
|
roadster: false,
|
|
102
106
|
roadsterPath: null,
|
|
103
107
|
roadsterDrawn: { shown: false, position: null, radiusPx: 0 },
|
|
@@ -179,6 +183,8 @@ export function createSpaceItem(model, deps) {
|
|
|
179
183
|
const scratchB = new three.Vector3();
|
|
180
184
|
// the orbit lines of a stage out from the Sun, kept while the stage, the scale and the day are the same
|
|
181
185
|
let regionLines = null;
|
|
186
|
+
// made when the first trail is shown: a view that never paints holds none of it
|
|
187
|
+
let paintOverlay = null;
|
|
182
188
|
let ended = false;
|
|
183
189
|
const slots = new Map();
|
|
184
190
|
const empty = (slot) => {
|
|
@@ -913,6 +919,24 @@ export function createSpaceItem(model, deps) {
|
|
|
913
919
|
if (trackDrawn === 0)
|
|
914
920
|
trackLine.visible = false;
|
|
915
921
|
model.orbitersDrawn = { count: Object.keys(orbiterPlaces).length, status: orbiterStatus, dim: orbitersDim, lines: linesDrawn, track: trackDrawn };
|
|
922
|
+
// the painted trail: stepped and uploaded only while the painted craft's body is drawn, and only when the shown moment moved
|
|
923
|
+
const paintedCraft = model.paint;
|
|
924
|
+
const paintSet = model.orbiterSet;
|
|
925
|
+
const paintBody = paintedCraft !== null && paintSet !== null && paintSet.ids.includes(paintedCraft.id) ? slots.get(paintSet.centre(paintedCraft.id))?.drawing : undefined;
|
|
926
|
+
const paintHost = paintBody !== undefined && paintBody.object.visible ? paintBody.object.children[0] : undefined;
|
|
927
|
+
if (paintedCraft !== null && paintSet !== null && paintHost !== undefined) {
|
|
928
|
+
const centre = paintSet.centre(paintedCraft.id);
|
|
929
|
+
const period = paintSet.period(paintedCraft.id);
|
|
930
|
+
const trail = model.paintTrail;
|
|
931
|
+
const upload = trail.step(model.time, BODIES[centre].radiusKm, (at) => {
|
|
932
|
+
const there = paintSet.position(paintedCraft.id, at);
|
|
933
|
+
return there === null ? null : groundUnder(centre, there, at);
|
|
934
|
+
}, period === null ? undefined : period * 86_400_000);
|
|
935
|
+
(paintOverlay ??= createPaintOverlay(three, model.paintTrail.data)).show(paintHost, paintMinute(model.time), trail.spanMinutes, upload);
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
paintOverlay?.hide();
|
|
939
|
+
}
|
|
916
940
|
model.roadsterDrawn = { shown: roadsterAt !== null, position: roadsterAt === null ? null : [roadsterAt[0] + origin[0], roadsterAt[1] + origin[1], roadsterAt[2] + origin[2]], radiusPx: roadsterPx };
|
|
917
941
|
// the arrowheads on the lines: small in screen pixels at the place, pointing the way the body goes (the lines run from the body once round in the order it goes, whichever way the clock runs)
|
|
918
942
|
const e = camera.matrixWorld.elements;
|
|
@@ -1169,6 +1193,7 @@ export function createSpaceItem(model, deps) {
|
|
|
1169
1193
|
dots?.dispose();
|
|
1170
1194
|
oortGeometry.dispose();
|
|
1171
1195
|
oortLines.material.dispose();
|
|
1196
|
+
paintOverlay?.dispose();
|
|
1172
1197
|
if (releaseTimer !== undefined)
|
|
1173
1198
|
clearTimeout(releaseTimer);
|
|
1174
1199
|
ended = true;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.40.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.40.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
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",
|
|
@@ -370,6 +370,11 @@
|
|
|
370
370
|
"import": "./dist/orbiters.js",
|
|
371
371
|
"default": "./dist/orbiters.js"
|
|
372
372
|
},
|
|
373
|
+
"./ground-track": {
|
|
374
|
+
"types": "./dist/ground-track.d.ts",
|
|
375
|
+
"import": "./dist/ground-track.js",
|
|
376
|
+
"default": "./dist/ground-track.js"
|
|
377
|
+
},
|
|
373
378
|
"./suncalc": {
|
|
374
379
|
"types": "./dist/suncalc.d.ts",
|
|
375
380
|
"import": "./dist/suncalc.js",
|