astraeus 0.9.0 → 0.9.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 +18 -0
- package/README.md +87 -27
- package/package.json +1 -1
- package/src/api/assembleScene.js +1 -1
- package/src/api/index.d.ts +1 -1
- package/src/api/planBodies.d.ts +2 -1
- package/src/api/planBodies.js +6 -1
- package/src/api/planPaths.d.ts +2 -0
- package/src/api/planPaths.js +14 -9
- package/src/api/providerPathTimes.d.ts +10 -0
- package/src/api/providerPathTimes.js +109 -0
- package/src/api/scene.d.ts +6 -0
- package/src/api/shownDuring.d.ts +12 -0
- package/src/api/shownDuring.js +30 -0
- package/src/api/story.d.ts +1 -1
- package/src/api/story.js +1 -1
- package/src/app/App.js +33 -16
- package/src/app/App.node.js +33 -16
- package/src/app/CameraController.d.ts +2 -1
- package/src/app/CameraController.js +4 -2
- package/src/app/sceneFrame.d.ts +14 -5
- package/src/app/sceneFrame.js +29 -19
- package/src/app/viewHiding.d.ts +8 -1
- package/src/app/viewHiding.js +23 -0
- package/src/core/pacing.d.ts +38 -6
- package/src/core/pacing.js +141 -21
- package/src/shell/AstraeusShell.d.ts +3 -1
- package/src/shell/AstraeusShell.js +25 -7
- package/src/shell/AstraeusShell.node.js +25 -7
- package/src/shell/ObjectControls.js +1 -1
- package/src/shell/experience.d.ts +7 -0
- package/src/shell/objectModel.d.ts +3 -2
- package/src/shell/objectModel.js +6 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** The moments a provider path's line is drawn at: 128 even ones plus extra ones where the line bends or the body moves fast, as seen from the path's centre (O-070). */
|
|
2
|
+
/** Even moments every path starts from. */
|
|
3
|
+
export const PROVIDER_SEED_SAMPLES = 128;
|
|
4
|
+
/** Most moments a provider path is drawn at. */
|
|
5
|
+
export const PROVIDER_MAX_SAMPLES = 4096;
|
|
6
|
+
/** An interval is split while the body sweeps more than this angle about the centre between its ends. */
|
|
7
|
+
const MAX_SWEEP_RAD = (3 * Math.PI) / 180;
|
|
8
|
+
/** An interval is split while its true midpoint lies farther than this fraction of its distance from the centre from the chord's midpoint (the body speeding up or slowing down shows here too). */
|
|
9
|
+
const MAX_CHORD_ERROR = 0.0025;
|
|
10
|
+
/** The position as three finite numbers, or null when the provider gave something else. */
|
|
11
|
+
const read = (positionAt, timeUtcMs) => {
|
|
12
|
+
const p = positionAt(timeUtcMs);
|
|
13
|
+
return p?.length === 3 && Number.isFinite(p[0]) && Number.isFinite(p[1]) && Number.isFinite(p[2]) ? [p[0], p[1], p[2]] : null;
|
|
14
|
+
};
|
|
15
|
+
/** The interval's score. */
|
|
16
|
+
function scored(a, b, pa, pb, positionAt) {
|
|
17
|
+
const mid = Math.floor((a + b) / 2);
|
|
18
|
+
const pm = read(positionAt, mid);
|
|
19
|
+
if (pm === null)
|
|
20
|
+
return { a, b, pa, pb, mid, pm: pa, score: 0 };
|
|
21
|
+
const w = (mid - a) / (b - a);
|
|
22
|
+
const na = Math.hypot(...pa);
|
|
23
|
+
const nb = Math.hypot(...pb);
|
|
24
|
+
const dot = pa[0] * pb[0] + pa[1] * pb[1] + pa[2] * pb[2];
|
|
25
|
+
const sweep = Math.acos(Math.max(-1, Math.min(1, dot / (na * nb))));
|
|
26
|
+
const chord = Math.hypot(pm[0] - (pa[0] + w * (pb[0] - pa[0])), pm[1] - (pa[1] + w * (pb[1] - pa[1])), pm[2] - (pa[2] + w * (pb[2] - pa[2])));
|
|
27
|
+
const reach = Math.max(Math.hypot(...pm), Math.min(na, nb));
|
|
28
|
+
const score = Math.max(sweep / MAX_SWEEP_RAD, chord / (MAX_CHORD_ERROR * reach));
|
|
29
|
+
return { a, b, pa, pb, mid, pm, score: Number.isFinite(score) ? score : 0 };
|
|
30
|
+
}
|
|
31
|
+
/** Max-heap on score; ties go to the earlier interval, so the result is the same every time. */
|
|
32
|
+
class Worst {
|
|
33
|
+
#items = [];
|
|
34
|
+
get size() {
|
|
35
|
+
return this.#items.length;
|
|
36
|
+
}
|
|
37
|
+
#before(i, j) {
|
|
38
|
+
const x = this.#items[i];
|
|
39
|
+
const y = this.#items[j];
|
|
40
|
+
return x.score > y.score || (x.score === y.score && x.a < y.a);
|
|
41
|
+
}
|
|
42
|
+
#swap(i, j) {
|
|
43
|
+
[this.#items[i], this.#items[j]] = [this.#items[j], this.#items[i]];
|
|
44
|
+
}
|
|
45
|
+
push(item) {
|
|
46
|
+
this.#items.push(item);
|
|
47
|
+
for (let i = this.#items.length - 1; i > 0;) {
|
|
48
|
+
const parent = (i - 1) >> 1;
|
|
49
|
+
if (!this.#before(i, parent))
|
|
50
|
+
break;
|
|
51
|
+
this.#swap(i, parent);
|
|
52
|
+
i = parent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
pop() {
|
|
56
|
+
const top = this.#items[0];
|
|
57
|
+
const last = this.#items.pop();
|
|
58
|
+
if (this.#items.length > 0) {
|
|
59
|
+
this.#items[0] = last;
|
|
60
|
+
for (let i = 0;;) {
|
|
61
|
+
let best = i;
|
|
62
|
+
for (const child of [2 * i + 1, 2 * i + 2])
|
|
63
|
+
if (child < this.#items.length && this.#before(child, best))
|
|
64
|
+
best = child;
|
|
65
|
+
if (best === i)
|
|
66
|
+
break;
|
|
67
|
+
this.#swap(i, best);
|
|
68
|
+
i = best;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return top;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Strictly increasing whole-millisecond moments from `startUtcMs` to `endUtcMs`: the 128 even ones (the first and last are the bounds), then midpoints of the intervals that bend
|
|
76
|
+
* or speed up most, until none is over the limits or there are 4,096. `positionAt` gives the body's position about the path's centre; if it throws or gives no position, the even moments stand alone.
|
|
77
|
+
*/
|
|
78
|
+
export function providerPathTimes(startUtcMs, endUtcMs, positionAt) {
|
|
79
|
+
const step = (endUtcMs - startUtcMs) / (PROVIDER_SEED_SAMPLES - 1);
|
|
80
|
+
const seeds = [...new Set(Array.from({ length: PROVIDER_SEED_SAMPLES }, (_, index) => Math.round(startUtcMs + index * step)))];
|
|
81
|
+
try {
|
|
82
|
+
return refined(seeds, positionAt);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return seeds; // a provider that cannot answer yet (its data is not loaded) keeps the even moments
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function refined(seeds, positionAt) {
|
|
89
|
+
const found = seeds.map((t) => read(positionAt, t));
|
|
90
|
+
const positions = found.filter((p) => p !== null);
|
|
91
|
+
if (positions.length < seeds.length)
|
|
92
|
+
return [...seeds]; // a position the provider does not give: the fault is named when the line is drawn
|
|
93
|
+
const heap = new Worst();
|
|
94
|
+
for (let i = 1; i < seeds.length; i += 1)
|
|
95
|
+
if (seeds[i] - seeds[i - 1] >= 2)
|
|
96
|
+
heap.push(scored(seeds[i - 1], seeds[i], positions[i - 1], positions[i], positionAt));
|
|
97
|
+
const times = new Set(seeds);
|
|
98
|
+
while (heap.size > 0 && times.size < PROVIDER_MAX_SAMPLES) {
|
|
99
|
+
const worst = heap.pop();
|
|
100
|
+
if (worst.score <= 1)
|
|
101
|
+
break;
|
|
102
|
+
times.add(worst.mid);
|
|
103
|
+
for (const [a, b, pa, pb] of [[worst.a, worst.mid, worst.pa, worst.pm], [worst.mid, worst.b, worst.pm, worst.pb]]) {
|
|
104
|
+
if (b - a >= 2)
|
|
105
|
+
heap.push(scored(a, b, pa, pb, positionAt));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [...times].sort((x, y) => x - y);
|
|
109
|
+
}
|
package/src/api/scene.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ import type { SceneActivityRead, SceneBodyRead, SceneBodySetRead, SceneEventRead
|
|
|
21
21
|
export type { SceneActivityRead, SceneBodyRead, SceneBodySetRead, SceneEventRead, SceneGroupRead, SceneMoonPanelRead, ScenePanelRead, ScenePlacesRead, ScenePathRead, SceneSkyFigureRead, SceneTimelineRead, SceneViewRead, SceneViewsRead } from "./sceneReads.js";
|
|
22
22
|
export type { SceneCamera } from "./planCamera.js";
|
|
23
23
|
import { type TimeInput } from "./time.js";
|
|
24
|
+
import type { ShownDuringInput } from "./shownDuring.js";
|
|
25
|
+
export type { ShownDuringInput } from "./shownDuring.js";
|
|
24
26
|
import type { SwitchesInput } from "./switches.js";
|
|
25
27
|
import type { LookInput } from "./look.js";
|
|
26
28
|
import type { ViewInput, ViewsOptions } from "./views.js";
|
|
@@ -41,6 +43,8 @@ export interface AddBodyOptions {
|
|
|
41
43
|
readonly showLabel?: boolean;
|
|
42
44
|
/** How far from the camera the body's label shows, in the camera's `distance` units (Earth radii, as `camera.setReach`); a positive finite number. When absent the scene's shared rule applies: no limit in a Sun-centred or fitted scene, else the camera reach (at least 500). */
|
|
43
45
|
readonly labelReachEarthRadii?: number;
|
|
46
|
+
/** Shows the body only within a span (`ShownDuringInput`). */
|
|
47
|
+
readonly shownDuring?: ShownDuringInput;
|
|
44
48
|
/** One or two plain sentences for the body's info card. */
|
|
45
49
|
readonly description?: string;
|
|
46
50
|
/** The body's colour on its info card and label, as a CSS hex colour such as "#9fd8ff"; the catalogue's own when absent. A bad value throws `bad-body`. */
|
|
@@ -132,6 +136,8 @@ export interface TrajectoryBase {
|
|
|
132
136
|
* Sorted, not overlapping, inside the path's span; a fault throws `bad-trajectory` naming the index. Where no span covers the time, `provenance` (or the illustrative default) shows.
|
|
133
137
|
*/
|
|
134
138
|
readonly provenanceSpans?: readonly ActivitySourceInput[];
|
|
139
|
+
/** Shows the path only within a span (`ShownDuringInput`). */
|
|
140
|
+
readonly shownDuring?: ShownDuringInput;
|
|
135
141
|
/** One or two plain sentences for the path's info card. */
|
|
136
142
|
readonly description?: string;
|
|
137
143
|
/** Published limits of the data, shown with the provenance. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ShownSpan } from "../shell/experience.js";
|
|
2
|
+
import { type TimeInput } from "./time.js";
|
|
3
|
+
/** Shown while `start <= t < end`; an absent end is unbounded, give at least one. Outside it nothing is drawn or pickable; `stateOf` is unchanged. */
|
|
4
|
+
export interface ShownDuringInput {
|
|
5
|
+
readonly start?: TimeInput;
|
|
6
|
+
readonly end?: TimeInput;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Checks a `shownDuring` input (API-04) and returns it in milliseconds (undefined when none is given). `call` is the public call's name, `code` its own error code
|
|
10
|
+
* (`bad-body` for `addBody` and `addBodyFromElements`, `bad-trajectory` for `addTrajectory`). Not an object, no end, a bad moment or an end not after the start throws.
|
|
11
|
+
*/
|
|
12
|
+
export declare function planShownDuring(call: string, id: string, code: "bad-body" | "bad-trajectory", input: ShownDuringInput | undefined): ShownSpan | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SceneError } from "./errors.js";
|
|
2
|
+
import { toUtcMs } from "./time.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks a `shownDuring` input (API-04) and returns it in milliseconds (undefined when none is given). `call` is the public call's name, `code` its own error code
|
|
5
|
+
* (`bad-body` for `addBody` and `addBodyFromElements`, `bad-trajectory` for `addTrajectory`). Not an object, no end, a bad moment or an end not after the start throws.
|
|
6
|
+
*/
|
|
7
|
+
export function planShownDuring(call, id, code, input) {
|
|
8
|
+
if (input === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
const bad = (message) => new SceneError(code, `${call}("${id}"): shownDuring ${message}`);
|
|
11
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
12
|
+
throw bad("must be an object { start?, end? }");
|
|
13
|
+
if (input.start === undefined && input.end === undefined)
|
|
14
|
+
throw bad("needs a start, an end or both");
|
|
15
|
+
const moment = (field, time) => {
|
|
16
|
+
if (time === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
try {
|
|
19
|
+
return toUtcMs(time, `${call}("${id}") shownDuring.${field}`);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw bad(`${field}: ${error instanceof Error ? error.message : String(error)}`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const startUtcMs = moment("start", input.start);
|
|
26
|
+
const endUtcMs = moment("end", input.end);
|
|
27
|
+
if (startUtcMs !== undefined && endUtcMs !== undefined && endUtcMs <= startUtcMs)
|
|
28
|
+
throw bad("must end after it starts");
|
|
29
|
+
return { ...(startUtcMs === undefined ? {} : { startUtcMs }), ...(endUtcMs === undefined ? {} : { endUtcMs }) };
|
|
30
|
+
}
|
package/src/api/story.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ export declare function panelPlaybackOf(input: StoryPanelPlaybackInput): PanelPl
|
|
|
146
146
|
/** The story panels resolved against the scene's events, anchors, objects and window; a mistake becomes a `bad-panels` SceneError. */
|
|
147
147
|
export declare function panelsOf(panels: readonly CheckedPanel[], playback: PanelPlayback, lookup: PanelLookup): StoryPanelSet;
|
|
148
148
|
/**
|
|
149
|
-
* The pacing the viewer runs, laid over the events: spans, then one zone per event of each rule's type. `pacedRate`
|
|
149
|
+
* The pacing the viewer runs, laid over the events: spans, then one zone per event of each rule's type. `pacedRate` lets faster spans set the cruise (the faster wins) and eases slower spans and event rules down from it (the slowest wins wherever they meet), whatever contains what.
|
|
150
150
|
* A rule whose type has no event throws `bad-timeline` naming the piece (a mistyped type would otherwise slow nothing, silently).
|
|
151
151
|
*/
|
|
152
152
|
export declare function pacingFor(setting: TimelineSetting, events: readonly TimelineEvent[], baseRate: number): Pacing | undefined;
|
package/src/api/story.js
CHANGED
|
@@ -186,7 +186,7 @@ function pacingOf(input, bad) {
|
|
|
186
186
|
return pieces.length === 0 ? undefined : pieces;
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
|
-
* The pacing the viewer runs, laid over the events: spans, then one zone per event of each rule's type. `pacedRate`
|
|
189
|
+
* The pacing the viewer runs, laid over the events: spans, then one zone per event of each rule's type. `pacedRate` lets faster spans set the cruise (the faster wins) and eases slower spans and event rules down from it (the slowest wins wherever they meet), whatever contains what.
|
|
190
190
|
* A rule whose type has no event throws `bad-timeline` naming the piece (a mistyped type would otherwise slow nothing, silently).
|
|
191
191
|
*/
|
|
192
192
|
export function pacingFor(setting, events, baseRate) {
|
package/src/app/App.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Suspense, useCallback, useEffect, useMemo, useRef, useState, useSyncExt
|
|
|
3
3
|
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
4
4
|
import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
|
|
5
5
|
import { activeEventZones, applyPacing, startPaceEase } from "../core/pacing.js";
|
|
6
|
+
import { frameTime } from "./sceneFrame.js";
|
|
6
7
|
import { openClock } from "./openClock.js";
|
|
7
8
|
import { createProvenance } from "../core/provenance.js";
|
|
8
9
|
import { pickerSwitch } from "./listSwitch.js";
|
|
@@ -35,7 +36,8 @@ import { displaySwitchItems, hostReachable, orbitStart, skyLineStart } from "./d
|
|
|
35
36
|
import { TRACE_FADE_SECONDS } from "../core/skyTrace.js";
|
|
36
37
|
import { aimAtFigure, DEFAULT_SKY_LINES, prefersReducedMotion, skyColoursOf, skyFadeInSecondsOf } from "./skyFigures.js";
|
|
37
38
|
import { labelStyleOf } from "./labelStyle.js";
|
|
38
|
-
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
39
|
+
import { experienceInView, hiddenByView, hiddenWithShownSpans, viewById } from "./viewHiding.js";
|
|
40
|
+
import { cameraIdsOf } from "../core/storyPanels.js";
|
|
39
41
|
import { baseGlowOf, glowLookOf, markerSettingsOf } from "./bodyDraw.js";
|
|
40
42
|
import { resolveLook } from "./look.js";
|
|
41
43
|
import { applyLook, desktopPicturesOf, lookReadOf, presentationOf, skySettingsOf } from "./liveLook.js";
|
|
@@ -311,7 +313,11 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
311
313
|
const [viewNow, setViewNow] = useState(null);
|
|
312
314
|
const [viewLink, setViewLink] = useState(null);
|
|
313
315
|
const [fills, setFills] = useState([]);
|
|
316
|
+
/** The ids the camera's last request named (a preset, a host `setCamera`, a story panel's camera): the one rule below holds the camera when one of them stops being shown. */
|
|
317
|
+
const cameraNamed = useRef([]);
|
|
318
|
+
const noteCameraIds = (request) => { const { bodies, toward } = cameraIdsOf(request); cameraNamed.current = toward === undefined ? bodies : [...bodies, toward]; };
|
|
314
319
|
const updateCameraRequest = useCallback((request) => {
|
|
320
|
+
noteCameraIds(request);
|
|
315
321
|
controls.current.cameraRequest = aimAtFigure(request, runtime.skyFigures);
|
|
316
322
|
}, [runtime]);
|
|
317
323
|
const turnToFigure = useCallback((id) => {
|
|
@@ -319,7 +325,15 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
319
325
|
if (now !== undefined && "lookOut" in now)
|
|
320
326
|
updateCameraRequest({ kind: "lookOut", body: now.lookOut, direction: id });
|
|
321
327
|
}, [updateCameraRequest]);
|
|
322
|
-
const holdCamera = useCallback(() => { controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
328
|
+
const holdCamera = useCallback(() => { cameraNamed.current = []; controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
329
|
+
/** O-071 (I-175): whatever named the camera's target, once that object is not shown at `timeUtcMs` the camera keeps its pose and stops following (`shownAt`, via `hiddenWithShownSpans`). */
|
|
330
|
+
const holdCameraOffShown = useCallback((timeUtcMs) => {
|
|
331
|
+
if (cameraNamed.current.length === 0)
|
|
332
|
+
return;
|
|
333
|
+
const out = hiddenWithShownSpans(undefined, experience.objects, timeUtcMs)?.objects;
|
|
334
|
+
if (out !== undefined && cameraNamed.current.some((id) => out.has(id)))
|
|
335
|
+
holdCamera();
|
|
336
|
+
}, [experience, holdCamera]);
|
|
323
337
|
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
324
338
|
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
325
339
|
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
@@ -404,13 +418,8 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
404
418
|
}, [host, stateNow]);
|
|
405
419
|
useEffect(() => {
|
|
406
420
|
const id = window.setInterval(() => {
|
|
407
|
-
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
408
|
-
|
|
409
|
-
runtime.clock.wrapWithin(runtime.loopWindow);
|
|
410
|
-
else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
|
|
411
|
-
runtime.clock.stopWithin(runtime.loopWindow);
|
|
412
|
-
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
413
|
-
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
421
|
+
// The readout wraps, stops and paces with the scene, so the shown time never rests past the end while looping and a host's playback reports follow the slow-downs.
|
|
422
|
+
frameTime(runtime, controls.current);
|
|
414
423
|
setClockSnapshot(runtime.clock.snapshot());
|
|
415
424
|
host?.publish(stateNow(), "playback");
|
|
416
425
|
}, 100);
|
|
@@ -419,6 +428,8 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
419
428
|
// The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
|
|
420
429
|
const seekTo = useCallback((timeUtcMs) => {
|
|
421
430
|
runtime.clock.seek(timeUtcMs);
|
|
431
|
+
if (controls.current.pace !== undefined)
|
|
432
|
+
delete controls.current.pace.last; // the paced step starts again from the new time
|
|
422
433
|
// A seek lands on the paced rate for the new time at once, not through a view-switch ease.
|
|
423
434
|
if (controls.current.pace !== undefined) {
|
|
424
435
|
delete controls.current.pace.ease;
|
|
@@ -450,18 +461,18 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
450
461
|
}, [runtime]);
|
|
451
462
|
// The same play handler the visitor's button reaches, so a host and a visitor share one clock.
|
|
452
463
|
const hostSetPlaying = setPlaying;
|
|
453
|
-
// The objects a host may point the camera at: those the showing view shows (read live, so a view switch is already counted).
|
|
464
|
+
// The objects a host may point the camera at: those the showing view shows and that are shown at the clock time (read live, so a view switch or a time move is already counted).
|
|
454
465
|
const cameraTargets = useCallback(() => {
|
|
455
|
-
const hidden = controls.current.viewHidden?.objects;
|
|
466
|
+
const hidden = hiddenWithShownSpans(controls.current.viewHidden, experience.objects, runtime.clock.snapshot().timeUtcMs)?.objects;
|
|
456
467
|
return experience.objects.map(({ id }) => id).filter((id) => hidden === undefined || !hidden.has(id));
|
|
457
|
-
}, [experience]);
|
|
468
|
+
}, [experience, runtime]);
|
|
458
469
|
const opening = useMemo(() => openingCamera(definition, runtime, search), []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
459
470
|
const readCamera = useCallback(() => {
|
|
460
471
|
const view = controls.current.viewReadout ?? opening;
|
|
461
472
|
return view === undefined ? undefined : { ...view };
|
|
462
473
|
}, [opening]);
|
|
463
474
|
// A host camera call is the last word: it is also kept in `hostCameraRequest`, so the opening view (first frame) and a view's own camera rule (shell) yield to it.
|
|
464
|
-
const setCamera = useCallback((request) => { controls.current.cameraRequest = controls.current.hostCameraRequest = aimAtFigure(request, runtime.skyFigures); }, [runtime]);
|
|
475
|
+
const setCamera = useCallback((request) => { noteCameraIds(request); controls.current.cameraRequest = controls.current.hostCameraRequest = aimAtFigure(request, runtime.skyFigures); }, [runtime]);
|
|
465
476
|
const hostCameraSet = useCallback(() => controls.current.hostCameraRequest != null, []);
|
|
466
477
|
const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
|
|
467
478
|
const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
|
|
@@ -473,6 +484,12 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
473
484
|
const panelTrace = useRef(null);
|
|
474
485
|
/** The panel whose actions were last applied (a host `setPanel` shows its panel at once, so `openStoryPanelId` cannot say whether the shell has opened it yet). */
|
|
475
486
|
const actedPanel = useRef(null);
|
|
487
|
+
/** Whether the objects a story panel's camera names are shown at the clock time; a request toward one outside its `shownDuring` span is refused as `setCamera` refuses it. */
|
|
488
|
+
const shownAtClock = useCallback((request) => {
|
|
489
|
+
const out = hiddenWithShownSpans(undefined, experience.objects, runtime.clock.snapshot().timeUtcMs)?.objects;
|
|
490
|
+
const { bodies, toward } = cameraIdsOf(request);
|
|
491
|
+
return out === undefined || ![...bodies, ...(toward === undefined ? [] : [toward])].some((id) => out.has(id));
|
|
492
|
+
}, [experience, runtime]);
|
|
476
493
|
/** The shell's open panel changed (a visitor, a host call already shown, playback crossing a panel, or a view switch dropping it); a change is told to the host, the opening panel is read at attach. */
|
|
477
494
|
const markOpenPanel = useCallback((id, cause) => {
|
|
478
495
|
const changed = (controls.current.openStoryPanelId ?? null) !== id;
|
|
@@ -491,7 +508,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
491
508
|
if (panel === undefined)
|
|
492
509
|
return;
|
|
493
510
|
// The panel's actions go through the host calls, in this order: camera, select, trace.
|
|
494
|
-
if (panel.camera !== undefined)
|
|
511
|
+
if (panel.camera !== undefined && shownAtClock(panel.camera))
|
|
495
512
|
setCamera(panel.camera);
|
|
496
513
|
if (panel.select === true && panel.objectId !== undefined)
|
|
497
514
|
selectWith(panel.objectId, true);
|
|
@@ -499,7 +516,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
499
516
|
hostTraceSkyFigure(panel.objectId, panel.trace.seconds, panel.trace.after);
|
|
500
517
|
panelTrace.current = panel.objectId;
|
|
501
518
|
}
|
|
502
|
-
}, [host, stateNow, definition, setCamera, selectWith, hostTraceSkyFigure, hostClearSkyTrace]);
|
|
519
|
+
}, [host, stateNow, definition, setCamera, shownAtClock, selectWith, hostTraceSkyFigure, hostClearSkyTrace]);
|
|
503
520
|
useEffect(() => {
|
|
504
521
|
if (host === undefined)
|
|
505
522
|
return undefined;
|
|
@@ -671,5 +688,5 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
671
688
|
}, onSeek: (timeUtcMs) => {
|
|
672
689
|
seekTo(timeUtcMs);
|
|
673
690
|
host?.publish(stateNow(), "visitor");
|
|
674
|
-
}, onCameraRequest: updateCameraRequest, onTurnToFigure: turnToFigure, onCameraHold: holdCamera, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
|
|
691
|
+
}, onCameraRequest: updateCameraRequest, onTurnToFigure: turnToFigure, onCameraHold: holdCamera, onTimeShown: holdCameraOffShown, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
|
|
675
692
|
}
|
package/src/app/App.node.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Suspense, useCallback, useEffect, useMemo, useRef, useState, useSyncExt
|
|
|
3
3
|
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
4
4
|
import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
|
|
5
5
|
import { activeEventZones, applyPacing, startPaceEase } from "../core/pacing.js";
|
|
6
|
+
import { frameTime } from "./sceneFrame.js";
|
|
6
7
|
import { openClock } from "./openClock.js";
|
|
7
8
|
import { createProvenance } from "../core/provenance.js";
|
|
8
9
|
import { pickerSwitch } from "./listSwitch.js";
|
|
@@ -35,7 +36,8 @@ import { displaySwitchItems, hostReachable, orbitStart, skyLineStart } from "./d
|
|
|
35
36
|
import { TRACE_FADE_SECONDS } from "../core/skyTrace.js";
|
|
36
37
|
import { aimAtFigure, DEFAULT_SKY_LINES, prefersReducedMotion, skyColoursOf, skyFadeInSecondsOf } from "./skyFigures.js";
|
|
37
38
|
import { labelStyleOf } from "./labelStyle.js";
|
|
38
|
-
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
39
|
+
import { experienceInView, hiddenByView, hiddenWithShownSpans, viewById } from "./viewHiding.js";
|
|
40
|
+
import { cameraIdsOf } from "../core/storyPanels.js";
|
|
39
41
|
import { baseGlowOf, glowLookOf, markerSettingsOf } from "./bodyDraw.js";
|
|
40
42
|
import { resolveLook } from "./look.js";
|
|
41
43
|
import { applyLook, desktopPicturesOf, lookReadOf, presentationOf, skySettingsOf } from "./liveLook.js";
|
|
@@ -311,7 +313,11 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
311
313
|
const [viewNow, setViewNow] = useState(null);
|
|
312
314
|
const [viewLink, setViewLink] = useState(null);
|
|
313
315
|
const [fills, setFills] = useState([]);
|
|
316
|
+
/** The ids the camera's last request named (a preset, a host `setCamera`, a story panel's camera): the one rule below holds the camera when one of them stops being shown. */
|
|
317
|
+
const cameraNamed = useRef([]);
|
|
318
|
+
const noteCameraIds = (request) => { const { bodies, toward } = cameraIdsOf(request); cameraNamed.current = toward === undefined ? bodies : [...bodies, toward]; };
|
|
314
319
|
const updateCameraRequest = useCallback((request) => {
|
|
320
|
+
noteCameraIds(request);
|
|
315
321
|
controls.current.cameraRequest = aimAtFigure(request, runtime.skyFigures);
|
|
316
322
|
}, [runtime]);
|
|
317
323
|
const turnToFigure = useCallback((id) => {
|
|
@@ -319,7 +325,15 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
319
325
|
if (now !== undefined && "lookOut" in now)
|
|
320
326
|
updateCameraRequest({ kind: "lookOut", body: now.lookOut, direction: id });
|
|
321
327
|
}, [updateCameraRequest]);
|
|
322
|
-
const holdCamera = useCallback(() => { controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
328
|
+
const holdCamera = useCallback(() => { cameraNamed.current = []; controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
329
|
+
/** O-071 (I-175): whatever named the camera's target, once that object is not shown at `timeUtcMs` the camera keeps its pose and stops following (`shownAt`, via `hiddenWithShownSpans`). */
|
|
330
|
+
const holdCameraOffShown = useCallback((timeUtcMs) => {
|
|
331
|
+
if (cameraNamed.current.length === 0)
|
|
332
|
+
return;
|
|
333
|
+
const out = hiddenWithShownSpans(undefined, experience.objects, timeUtcMs)?.objects;
|
|
334
|
+
if (out !== undefined && cameraNamed.current.some((id) => out.has(id)))
|
|
335
|
+
holdCamera();
|
|
336
|
+
}, [experience, holdCamera]);
|
|
323
337
|
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
324
338
|
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
325
339
|
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
@@ -404,13 +418,8 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
404
418
|
}, [host, stateNow]);
|
|
405
419
|
useEffect(() => {
|
|
406
420
|
const id = window.setInterval(() => {
|
|
407
|
-
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
408
|
-
|
|
409
|
-
runtime.clock.wrapWithin(runtime.loopWindow);
|
|
410
|
-
else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
|
|
411
|
-
runtime.clock.stopWithin(runtime.loopWindow);
|
|
412
|
-
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
413
|
-
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
421
|
+
// The readout wraps, stops and paces with the scene, so the shown time never rests past the end while looping and a host's playback reports follow the slow-downs.
|
|
422
|
+
frameTime(runtime, controls.current);
|
|
414
423
|
setClockSnapshot(runtime.clock.snapshot());
|
|
415
424
|
host?.publish(stateNow(), "playback");
|
|
416
425
|
}, 100);
|
|
@@ -419,6 +428,8 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
419
428
|
// The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
|
|
420
429
|
const seekTo = useCallback((timeUtcMs) => {
|
|
421
430
|
runtime.clock.seek(timeUtcMs);
|
|
431
|
+
if (controls.current.pace !== undefined)
|
|
432
|
+
delete controls.current.pace.last; // the paced step starts again from the new time
|
|
422
433
|
// A seek lands on the paced rate for the new time at once, not through a view-switch ease.
|
|
423
434
|
if (controls.current.pace !== undefined) {
|
|
424
435
|
delete controls.current.pace.ease;
|
|
@@ -450,18 +461,18 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
450
461
|
}, [runtime]);
|
|
451
462
|
// The same play handler the visitor's button reaches, so a host and a visitor share one clock.
|
|
452
463
|
const hostSetPlaying = setPlaying;
|
|
453
|
-
// The objects a host may point the camera at: those the showing view shows (read live, so a view switch is already counted).
|
|
464
|
+
// The objects a host may point the camera at: those the showing view shows and that are shown at the clock time (read live, so a view switch or a time move is already counted).
|
|
454
465
|
const cameraTargets = useCallback(() => {
|
|
455
|
-
const hidden = controls.current.viewHidden?.objects;
|
|
466
|
+
const hidden = hiddenWithShownSpans(controls.current.viewHidden, experience.objects, runtime.clock.snapshot().timeUtcMs)?.objects;
|
|
456
467
|
return experience.objects.map(({ id }) => id).filter((id) => hidden === undefined || !hidden.has(id));
|
|
457
|
-
}, [experience]);
|
|
468
|
+
}, [experience, runtime]);
|
|
458
469
|
const opening = useMemo(() => openingCamera(definition, runtime, search), []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
459
470
|
const readCamera = useCallback(() => {
|
|
460
471
|
const view = controls.current.viewReadout ?? opening;
|
|
461
472
|
return view === undefined ? undefined : { ...view };
|
|
462
473
|
}, [opening]);
|
|
463
474
|
// A host camera call is the last word: it is also kept in `hostCameraRequest`, so the opening view (first frame) and a view's own camera rule (shell) yield to it.
|
|
464
|
-
const setCamera = useCallback((request) => { controls.current.cameraRequest = controls.current.hostCameraRequest = aimAtFigure(request, runtime.skyFigures); }, [runtime]);
|
|
475
|
+
const setCamera = useCallback((request) => { noteCameraIds(request); controls.current.cameraRequest = controls.current.hostCameraRequest = aimAtFigure(request, runtime.skyFigures); }, [runtime]);
|
|
465
476
|
const hostCameraSet = useCallback(() => controls.current.hostCameraRequest != null, []);
|
|
466
477
|
const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
|
|
467
478
|
const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
|
|
@@ -473,6 +484,12 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
473
484
|
const panelTrace = useRef(null);
|
|
474
485
|
/** The panel whose actions were last applied (a host `setPanel` shows its panel at once, so `openStoryPanelId` cannot say whether the shell has opened it yet). */
|
|
475
486
|
const actedPanel = useRef(null);
|
|
487
|
+
/** Whether the objects a story panel's camera names are shown at the clock time; a request toward one outside its `shownDuring` span is refused as `setCamera` refuses it. */
|
|
488
|
+
const shownAtClock = useCallback((request) => {
|
|
489
|
+
const out = hiddenWithShownSpans(undefined, experience.objects, runtime.clock.snapshot().timeUtcMs)?.objects;
|
|
490
|
+
const { bodies, toward } = cameraIdsOf(request);
|
|
491
|
+
return out === undefined || ![...bodies, ...(toward === undefined ? [] : [toward])].some((id) => out.has(id));
|
|
492
|
+
}, [experience, runtime]);
|
|
476
493
|
/** The shell's open panel changed (a visitor, a host call already shown, playback crossing a panel, or a view switch dropping it); a change is told to the host, the opening panel is read at attach. */
|
|
477
494
|
const markOpenPanel = useCallback((id, cause) => {
|
|
478
495
|
const changed = (controls.current.openStoryPanelId ?? null) !== id;
|
|
@@ -491,7 +508,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
491
508
|
if (panel === undefined)
|
|
492
509
|
return;
|
|
493
510
|
// The panel's actions go through the host calls, in this order: camera, select, trace.
|
|
494
|
-
if (panel.camera !== undefined)
|
|
511
|
+
if (panel.camera !== undefined && shownAtClock(panel.camera))
|
|
495
512
|
setCamera(panel.camera);
|
|
496
513
|
if (panel.select === true && panel.objectId !== undefined)
|
|
497
514
|
selectWith(panel.objectId, true);
|
|
@@ -499,7 +516,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
499
516
|
hostTraceSkyFigure(panel.objectId, panel.trace.seconds, panel.trace.after);
|
|
500
517
|
panelTrace.current = panel.objectId;
|
|
501
518
|
}
|
|
502
|
-
}, [host, stateNow, definition, setCamera, selectWith, hostTraceSkyFigure, hostClearSkyTrace]);
|
|
519
|
+
}, [host, stateNow, definition, setCamera, shownAtClock, selectWith, hostTraceSkyFigure, hostClearSkyTrace]);
|
|
503
520
|
useEffect(() => {
|
|
504
521
|
if (host === undefined)
|
|
505
522
|
return undefined;
|
|
@@ -671,5 +688,5 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
671
688
|
}, onSeek: (timeUtcMs) => {
|
|
672
689
|
seekTo(timeUtcMs);
|
|
673
690
|
host?.publish(stateNow(), "visitor");
|
|
674
|
-
}, onCameraRequest: updateCameraRequest, onTurnToFigure: turnToFigure, onCameraHold: holdCamera, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
|
|
691
|
+
}, onCameraRequest: updateCameraRequest, onTurnToFigure: turnToFigure, onCameraHold: holdCamera, onTimeShown: holdCameraOffShown, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
|
|
675
692
|
}
|
|
@@ -74,7 +74,8 @@ export declare function switchFocus(state: OrbitCameraState, focus: FocusId, new
|
|
|
74
74
|
* Step 1 (before bodies are placed): computes the absolute target/camera in Float64 render axes
|
|
75
75
|
* and rebases the floating origin when the target drifts away from it, so bodies and camera
|
|
76
76
|
* always use the same origin within a frame. Scientific state is never read or written here.
|
|
77
|
+
* With `reducedMotion` the distance, angles and focus tween land on their targets in one frame.
|
|
77
78
|
*/
|
|
78
|
-
export declare function resolveCamera(state: OrbitCameraState, focusAbsolute: RenderVector, origin: FloatingOrigin, deltaSeconds: number, rebaseThreshold: number, up?: RenderVector): void;
|
|
79
|
+
export declare function resolveCamera(state: OrbitCameraState, focusAbsolute: RenderVector, origin: FloatingOrigin, deltaSeconds: number, rebaseThreshold: number, up?: RenderVector, reducedMotion?: boolean): void;
|
|
79
80
|
/** Step 2: writes the origin-relative camera pose and clipping planes. */
|
|
80
81
|
export declare function poseCamera(camera: PerspectiveCamera, state: OrbitCameraState, focusRadius: number, origin: FloatingOrigin, far?: number, up?: RenderVector): void;
|
|
@@ -140,9 +140,11 @@ export function switchFocus(state, focus, newTargetAbsolute) {
|
|
|
140
140
|
* Step 1 (before bodies are placed): computes the absolute target/camera in Float64 render axes
|
|
141
141
|
* and rebases the floating origin when the target drifts away from it, so bodies and camera
|
|
142
142
|
* always use the same origin within a frame. Scientific state is never read or written here.
|
|
143
|
+
* With `reducedMotion` the distance, angles and focus tween land on their targets in one frame.
|
|
143
144
|
*/
|
|
144
|
-
export function resolveCamera(state, focusAbsolute, origin, deltaSeconds, rebaseThreshold, up = EQUATORIAL_UP) {
|
|
145
|
-
|
|
145
|
+
export function resolveCamera(state, focusAbsolute, origin, deltaSeconds, rebaseThreshold, up = EQUATORIAL_UP, reducedMotion = false) {
|
|
146
|
+
// Reduced motion: every eased move arrives within this frame (decay 0, blend 1).
|
|
147
|
+
const decay = reducedMotion ? 0 : Math.exp(-TRANSITION_RATE_PER_S * deltaSeconds);
|
|
146
148
|
const blend = 1 - decay;
|
|
147
149
|
state.distance += (state.targetDistance - state.distance) * blend;
|
|
148
150
|
if (Math.abs(state.targetDistance - state.distance) < 1e-9)
|
package/src/app/sceneFrame.d.ts
CHANGED
|
@@ -131,8 +131,11 @@ export interface CameraStep {
|
|
|
131
131
|
export declare function viewUpOf(ctx: Pick<FrameContext, "runtime" | "controls">): RenderVector;
|
|
132
132
|
/** A frame is drawn only once every body's group and orientation node is mounted. */
|
|
133
133
|
export declare function bodiesMounted(runtime: SceneRuntime, refs: BodyRefs): boolean;
|
|
134
|
-
/**
|
|
135
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Stage 0: the time of this frame. While pacing is in charge the clock is first stepped through the frame's real time under the paced rate (so no frame passes over a slow-down); looping playback then wraps inside its window,
|
|
136
|
+
* and other playback stops on the window's edge (a scene with a timeline bar). A wrap or stop lands on the paced rate for its new time at once.
|
|
137
|
+
*/
|
|
138
|
+
export declare function frameTime(runtime: SceneRuntime, controls: Pick<SceneControls, "loop" | "paceAuto" | "pace">, nowMs?: number): number;
|
|
136
139
|
/** Stage 1: brings every view to the time of the frame. Returns the live body-set look. */
|
|
137
140
|
export declare function syncViews(ctx: FrameContext, t: number): BodySetLook;
|
|
138
141
|
/** Stage 2: places the composition about the scene centre and keeps the camera's framing when the scale policy changed. */
|
|
@@ -149,12 +152,18 @@ export declare function placeSkyFigures(ctx: FrameContext): void;
|
|
|
149
152
|
export declare function advanceSkyTraces(ctx: FrameContext): void;
|
|
150
153
|
/** Stage 5: places every view about the floating origin and publishes the views' readouts. Returns the hover brightness gain. */
|
|
151
154
|
export declare function placeViews(ctx: FrameContext, t: number, placed: PlacedScene, setLook: BodySetLook): number;
|
|
152
|
-
/** What this frame hides: the view's hidden ids, and the body the camera stands inside while looking out (the one hidden-set path, read by the visibility, label and tap stages). */
|
|
153
|
-
export declare function hiddenOf(ctx: Pick<FrameContext, "controls" | "orbit"
|
|
155
|
+
/** What this frame hides: the view's hidden ids, the objects not shown at clock time `t` (`shownDuring`; none when `t` is not given), and the body the camera stands inside while looking out (the one hidden-set path, read by the visibility, label and tap stages). */
|
|
156
|
+
export declare function hiddenOf(ctx: Pick<FrameContext, "controls" | "orbit">, t?: number): ViewHidden | undefined;
|
|
154
157
|
/** Stage 5b: shows or hides each drawn group by the current view's hidden ids (bodies, paths, point groups, body sets). One set, read here; nothing is rebuilt. */
|
|
155
|
-
export declare function applyViewVisibility(ctx: FrameContext): void;
|
|
158
|
+
export declare function applyViewVisibility(ctx: FrameContext, t?: number): void;
|
|
156
159
|
/** A mounted body's drawn sphere and radius for the feature markers, or null when the body is not drawn as a sphere. */
|
|
157
160
|
export declare function featureHostOf(assets: readonly BodyAsset[], parts: ReadonlyMap<BodyId, BodyParts>, id: string, policy: ScalePolicy): FeatureHost | null;
|
|
161
|
+
/** What the labels and taps see under the current view: the objects and body sets it shows, and the label-hidden ids with the view's own added. Allocates only when a view hides something. */
|
|
162
|
+
export declare function shownUnderView(ctx: FrameContext, t?: number): {
|
|
163
|
+
objects: readonly import("../shell/experience.js").ExperienceObject[];
|
|
164
|
+
bodySetViews: import("./BodySetView.js").BodySetView[];
|
|
165
|
+
hiddenLabels: Set<string> | undefined;
|
|
166
|
+
};
|
|
158
167
|
/** Stage 6: updates the overlay layers (names, story and feature markers) and rebuilds what a tap or hover can pick. */
|
|
159
168
|
export declare function updateOverlays(ctx: FrameContext, t: number, step: CameraStep, hoverGain: number): void;
|
|
160
169
|
/** Stage 7: places each body's light and builds the frame readout the shell reads. */
|