@johnmorrisdotca/wakusei-planets 0.53.0 → 0.55.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 +23 -0
- package/README.md +3 -3
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +19 -0
- package/dist/space/element.js +111 -6
- package/dist/space/hold.d.ts +217 -0
- package/dist/space/hold.js +248 -0
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/scene.d.ts +32 -0
- package/dist/space/scene.js +69 -6
- package/dist/space/travel.d.ts +62 -4
- package/dist/space/travel.js +761 -51
- package/dist/surface/drive.d.ts +22 -4
- package/dist/surface/drive.js +11 -5
- package/dist/surface/element.d.ts +15 -1
- package/dist/surface/element.js +27 -2
- package/dist/surface/index.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/surface/drive.d.ts
CHANGED
|
@@ -157,25 +157,43 @@ export interface DriveView {
|
|
|
157
157
|
azimuth: number;
|
|
158
158
|
pitch: number;
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* What a drag does in the chase view of the rover: `head` (the default of the element, its `drive-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place 6.5 m behind the rover
|
|
162
|
+
* and the scene turns round it; `orbit` takes the camera round the rover as it looks about, so the rover stays in the same place in the picture and is seen from every side, as the chase view was up to 0.55.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* import type { DriveDrag } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
167
|
+
*
|
|
168
|
+
* const drags: DriveDrag[] = ["head", "orbit"];
|
|
169
|
+
* console.log(drags.join(" or "));
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export type DriveDrag = "head" | "orbit";
|
|
160
173
|
/**
|
|
161
174
|
* The eyes for a view of the rover. The chase view stands 6.5 m behind it and 2.8 m up (never under the ground), looking at it; the seat view is the commander's eyes in the left seat, looking along the rover's heading
|
|
162
|
-
* and tilting with it. `offset` is the driver's own turn of the view from a drag (degrees), added to the direction either looks in.
|
|
175
|
+
* and tilting with it. `offset` is the driver's own turn of the view from a drag (degrees), added to the direction either looks in. In the chase view `drag` says what that turn does: with `head` the eyes stay where the rover
|
|
176
|
+
* puts them with no drag and only the way they look turns, so the rover leaves the picture as the view turns away; with `orbit` (what a call without it does, as before) the eyes go round the rover as they look about.
|
|
177
|
+
* The seat view turns in place either way.
|
|
163
178
|
*
|
|
164
179
|
* @param state - The rover.
|
|
165
180
|
* @param view - `chase` or `seat`.
|
|
166
181
|
* @param offset - The driver's turn of the view, degrees right and up.
|
|
167
182
|
* @param ground - The ground's height over the site's ground at a place.
|
|
183
|
+
* @param drag - What a drag does in the chase view: `head` or `orbit` (the default).
|
|
168
184
|
* @returns The eyes.
|
|
169
185
|
*
|
|
170
186
|
* @example
|
|
171
187
|
* ```ts
|
|
172
188
|
* import { driveView, startDrive } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
173
189
|
*
|
|
174
|
-
* const
|
|
175
|
-
*
|
|
190
|
+
* const rover = startDrive(0, 0, 0, 0);
|
|
191
|
+
* const view = driveView(rover, "chase", { azimuth: 0, pitch: 0 }, () => 0);
|
|
192
|
+
* const turned = driveView(rover, "chase", { azimuth: 90, pitch: 0 }, () => 0, "head");
|
|
193
|
+
* console.log(view.eye.north.toFixed(1), turned.eye.north.toFixed(1), turned.azimuth);
|
|
176
194
|
* ```
|
|
177
195
|
*/
|
|
178
196
|
export declare function driveView(state: DriveState, view: "chase" | "seat", offset: {
|
|
179
197
|
azimuth: number;
|
|
180
198
|
pitch: number;
|
|
181
|
-
}, ground: (east: number, north: number) => number): DriveView;
|
|
199
|
+
}, ground: (east: number, north: number) => number, drag?: DriveDrag): DriveView;
|
package/dist/surface/drive.js
CHANGED
|
@@ -218,28 +218,34 @@ export function driveParts(state) {
|
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
220
|
* The eyes for a view of the rover. The chase view stands 6.5 m behind it and 2.8 m up (never under the ground), looking at it; the seat view is the commander's eyes in the left seat, looking along the rover's heading
|
|
221
|
-
* and tilting with it. `offset` is the driver's own turn of the view from a drag (degrees), added to the direction either looks in.
|
|
221
|
+
* and tilting with it. `offset` is the driver's own turn of the view from a drag (degrees), added to the direction either looks in. In the chase view `drag` says what that turn does: with `head` the eyes stay where the rover
|
|
222
|
+
* puts them with no drag and only the way they look turns, so the rover leaves the picture as the view turns away; with `orbit` (what a call without it does, as before) the eyes go round the rover as they look about.
|
|
223
|
+
* The seat view turns in place either way.
|
|
222
224
|
*
|
|
223
225
|
* @param state - The rover.
|
|
224
226
|
* @param view - `chase` or `seat`.
|
|
225
227
|
* @param offset - The driver's turn of the view, degrees right and up.
|
|
226
228
|
* @param ground - The ground's height over the site's ground at a place.
|
|
229
|
+
* @param drag - What a drag does in the chase view: `head` or `orbit` (the default).
|
|
227
230
|
* @returns The eyes.
|
|
228
231
|
*
|
|
229
232
|
* @example
|
|
230
233
|
* ```ts
|
|
231
234
|
* import { driveView, startDrive } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
232
235
|
*
|
|
233
|
-
* const
|
|
234
|
-
*
|
|
236
|
+
* const rover = startDrive(0, 0, 0, 0);
|
|
237
|
+
* const view = driveView(rover, "chase", { azimuth: 0, pitch: 0 }, () => 0);
|
|
238
|
+
* const turned = driveView(rover, "chase", { azimuth: 90, pitch: 0 }, () => 0, "head");
|
|
239
|
+
* console.log(view.eye.north.toFixed(1), turned.eye.north.toFixed(1), turned.azimuth);
|
|
235
240
|
* ```
|
|
236
241
|
*/
|
|
237
|
-
export function driveView(state, view, offset, ground) {
|
|
242
|
+
export function driveView(state, view, offset, ground, drag = "orbit") {
|
|
238
243
|
if (view === "seat") {
|
|
239
244
|
const eye = toWorld(state, ROVER.seat);
|
|
240
245
|
return { eye: { east: eye[0], north: eye[2], up: eye[1] }, azimuth: (((state.heading + offset.azimuth) % 360) + 360) % 360, pitch: state.pitch / RAD + offset.pitch };
|
|
241
246
|
}
|
|
242
|
-
|
|
247
|
+
// the eyes stand behind the rover along the heading turned by the drag (`orbit`: they go round it) or along the heading alone (`head`: they keep their place and only the look turns)
|
|
248
|
+
const a = (state.heading + (drag === "head" ? 0 : offset.azimuth)) * RAD;
|
|
243
249
|
const [east, north] = [state.east - Math.sin(a) * 6.5, state.north - Math.cos(a) * 6.5];
|
|
244
250
|
const up = Math.max(state.y + 2.8, ground(east, north) + 1.4);
|
|
245
251
|
const drop = (up - (state.y + 1.0)) / 6.5;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SharedRenderer } from "@johnmorrisdotca/kazoku-ui/renderer";
|
|
2
2
|
import type { ThreeParts } from "../scene/body.ts";
|
|
3
3
|
import { setThreeLoader } from "../scene/shared.ts";
|
|
4
|
-
import { type DriveState } from "./drive.ts";
|
|
4
|
+
import { type DriveDrag, type DriveState } from "./drive.ts";
|
|
5
5
|
import { type HeightLevel, type TerrainManifest } from "./height.ts";
|
|
6
6
|
import { type TerrainProgress } from "./load.ts";
|
|
7
7
|
import { type SurfaceScene } from "./scene.ts";
|
|
@@ -102,6 +102,20 @@ export declare class WakuseiSurface extends HTMLElement {
|
|
|
102
102
|
/** Which view of the rover: `chase` (from behind and above, the default) or `seat` (the commander's). The key C turns from one to the other. */
|
|
103
103
|
get driveCamera(): "chase" | "seat";
|
|
104
104
|
set driveCamera(value: "chase" | "seat");
|
|
105
|
+
/**
|
|
106
|
+
* What a drag does in the chase view: `head` (the default; the attribute `drive-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place 6.5 m behind the rover and the rover leaves
|
|
107
|
+
* the picture as you look away and comes back when you look back; `orbit` takes the camera round the rover as it looks about, as the chase view did up to 0.55. The seat view turns in place either way. Set while driving it
|
|
108
|
+
* moves the camera at once and keeps the drive.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const surface = document.querySelector("wakusei-surface") as HTMLElement & { driveDrag: "head" | "orbit" };
|
|
113
|
+
* surface.driveDrag = "orbit";
|
|
114
|
+
* console.log(surface.driveDrag);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
get driveDrag(): DriveDrag;
|
|
118
|
+
set driveDrag(value: DriveDrag);
|
|
105
119
|
/** The rover being driven, or `undefined` when it is not. */
|
|
106
120
|
get vehicle(): DriveState | undefined;
|
|
107
121
|
/**
|
package/dist/surface/element.js
CHANGED
|
@@ -66,7 +66,7 @@ const num = (value, fallback) => {
|
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
68
|
export class WakuseiSurface extends HTMLElement {
|
|
69
|
-
static observedAttributes = ["quality", "shadows", "detail", "exposure", "site", "time", "heading", "pitch", "fov", "tiles", "lang", "body", "standby", "scale", "stick", "objects", "drive", "drive-camera", "watch", "watch-from", "watch-camera"];
|
|
69
|
+
static observedAttributes = ["quality", "shadows", "detail", "exposure", "site", "time", "heading", "pitch", "fov", "tiles", "lang", "body", "standby", "scale", "stick", "objects", "drive", "drive-camera", "drive-drag", "watch", "watch-from", "watch-camera"];
|
|
70
70
|
#root;
|
|
71
71
|
#stage;
|
|
72
72
|
#noteEl;
|
|
@@ -259,6 +259,13 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
259
259
|
this.driveCamera = this.getAttribute("drive-camera") === "seat" ? "seat" : "chase";
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
+
if (name === "drive-drag") {
|
|
263
|
+
if (this.#vehicle !== undefined) {
|
|
264
|
+
this.#syncDriveCamera();
|
|
265
|
+
this.#changed();
|
|
266
|
+
}
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
262
269
|
if (name === "stick") {
|
|
263
270
|
this.#showStick();
|
|
264
271
|
return;
|
|
@@ -507,6 +514,24 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
507
514
|
this.#syncDriveCamera();
|
|
508
515
|
this.#changed();
|
|
509
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* What a drag does in the chase view: `head` (the default; the attribute `drive-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place 6.5 m behind the rover and the rover leaves
|
|
519
|
+
* the picture as you look away and comes back when you look back; `orbit` takes the camera round the rover as it looks about, as the chase view did up to 0.55. The seat view turns in place either way. Set while driving it
|
|
520
|
+
* moves the camera at once and keeps the drive.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```ts
|
|
524
|
+
* const surface = document.querySelector("wakusei-surface") as HTMLElement & { driveDrag: "head" | "orbit" };
|
|
525
|
+
* surface.driveDrag = "orbit";
|
|
526
|
+
* console.log(surface.driveDrag);
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
529
|
+
get driveDrag() {
|
|
530
|
+
return this.getAttribute("drive-drag") === "orbit" ? "orbit" : "head";
|
|
531
|
+
}
|
|
532
|
+
set driveDrag(value) {
|
|
533
|
+
this.setAttribute("drive-drag", value === "orbit" ? "orbit" : "head");
|
|
534
|
+
}
|
|
510
535
|
/** The rover being driven, or `undefined` when it is not. */
|
|
511
536
|
get vehicle() {
|
|
512
537
|
return this.#vehicle === undefined ? undefined : { ...this.#vehicle, spin: [...this.#vehicle.spin] };
|
|
@@ -545,7 +570,7 @@ export class WakuseiSurface extends HTMLElement {
|
|
|
545
570
|
const v = this.#vehicle;
|
|
546
571
|
if (v === undefined)
|
|
547
572
|
return;
|
|
548
|
-
const view = driveView(v, this.#driveCamera, this.#camOffset, (e, n) => this.#groundAt(e, n));
|
|
573
|
+
const view = driveView(v, this.#driveCamera, this.#camOffset, (e, n) => this.#groundAt(e, n), this.driveDrag);
|
|
549
574
|
this.#at = { east: view.eye.east, north: view.eye.north };
|
|
550
575
|
this.#driveEyeUp = view.eye.up;
|
|
551
576
|
this.#look = clampLook({ azimuth: view.azimuth, pitch: view.pitch, fov: this.#look.fov });
|
package/dist/surface/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { SurfaceState } from "./element.ts";
|
|
|
7
7
|
export { ascentParts, landerParts, roverParts } from "./shapes.ts";
|
|
8
8
|
export { calloutsBy, CALLOUTS, clockText, LANDING, landingAt, type Callout, type LandingPose } from "./landing.ts";
|
|
9
9
|
export { DustField } from "./dust.ts";
|
|
10
|
-
export { driveParts, driveStep, driveView, startDrive, ROVER, type DriveInput, type DriveState, type DriveView } from "./drive.ts";
|
|
10
|
+
export { driveParts, driveStep, driveView, startDrive, ROVER, type DriveDrag, type DriveInput, type DriveState, type DriveView } from "./drive.ts";
|
|
11
11
|
export { keepAway, objectParts, objectsOf, partShadows, traverseOf, KEEP_OUT, type Part, type SiteObject } from "./objects.ts";
|
|
12
12
|
export { craterIn, craterProfile, madeGround, setKeepOut, rimBoost, rocksAround, standingPlace, type Crater, type Rock } from "./detail.ts";
|
|
13
13
|
export { rockMesh, type RockMesh } from "./rocks.ts";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.54.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.54.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.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",
|