@intentius/behold 0.29.42 → 0.29.44
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/AGENTS.md +77 -0
- package/dist/cli.js +3969 -1918
- package/package.json +1 -1
- package/web/app.js +1463 -80
- package/web/carve-narration.js +33 -1
- package/web/chant-live-pace.js +138 -0
- package/web/chant-live-pace.test.js +116 -0
- package/web/chant-pr-marks.js +417 -39
- package/web/chant-pr-marks.test.js +208 -4
- package/web/collision-marks.js +124 -0
- package/web/collision-marks.test.js +89 -0
- package/web/cone.js +269 -0
- package/web/cone.test.js +213 -0
- package/web/dots-cards.js +362 -0
- package/web/dots-cards.test.js +303 -0
- package/web/dots-live.test.js +151 -1
- package/web/dots-lod.js +20 -0
- package/web/dots-lod.test.js +19 -1
- package/web/dots-scene.js +110 -10
- package/web/dots.js +489 -87
- package/web/embed.js +17 -1
- package/web/embed.test.js +19 -1
- package/web/event-help-modal.js +85 -3
- package/web/event-help-modal.test.js +85 -1
- package/web/feature-flags.js +143 -0
- package/web/feature-flags.test.js +96 -0
- package/web/index.html +33 -0
- package/web/kiosk-carve.js +59 -6
- package/web/kiosk-event-help-ui.js +150 -19
- package/web/kiosk-event-help.js +102 -15
- package/web/kiosk-event-help.test.js +58 -1
- package/web/kiosk-metrics.js +4 -3
- package/web/kiosk-runs.js +8 -5
- package/web/kiosk-shot.js +157 -3
- package/web/kiosk-shot.test.js +223 -1
- package/web/kiosk-source.js +43 -0
- package/web/kiosk-source.test.js +39 -0
- package/web/kiosk-story-gate.test.js +44 -0
- package/web/kiosk-track.js +312 -0
- package/web/kiosk-track.test.js +148 -0
- package/web/kiosk-unknown-step.test.js +58 -0
- package/web/kiosk-vendor.js +71 -4
- package/web/kiosk-vendor.test.js +103 -3
- package/web/kiosk-watch.js +154 -1
- package/web/kiosk-watch.test.js +53 -1
- package/web/kiosk.html +57 -22
- package/web/kiosk.js +566 -53
- package/web/kiosk.test.js +2 -1
- package/web/small-stage.test.js +150 -0
- package/web/terragucci-blocked.test.js +192 -0
- package/web/terragucci-change.js +197 -17
- package/web/terragucci-components-live.js +189 -13
- package/web/terragucci-live-pace.js +92 -0
- package/web/terragucci-wave-results.test.js +125 -0
- package/web/terralith.html +7 -7
- package/web/tg-outside.js +124 -0
- package/web/tg-outside.test.js +100 -0
- package/web/tg-read-pills.js +122 -0
- package/web/tg-read-pills.test.js +117 -0
- package/web/theme.js +13 -1
- package/web/theme.test.js +21 -1
- package/web/tooltip.js +19 -7
- package/web/tooltip.test.js +15 -0
- package/web/tours/terralith.json +4 -4
- package/web/trunk-lane.test.js +1 -1
- package/web/view-url.js +8 -2
- package/web/why.js +129 -1
- package/web/why.test.js +113 -1
package/web/dots.js
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
import { readCarve, carveShow, walkthroughShow, phaseAt } from "./dots-recording.js";
|
|
24
24
|
import { parentsOf } from "./dots-layout.js";
|
|
25
|
-
import { buildScene, takeoffsBy, firstLandings, flightPoint, easeInOut, replayClock, BOX } from "./dots-scene.js";
|
|
26
|
-
import { cardMorph, discMorph, discRadius, levelOf, caption, railMarks, railPos, lerp } from "./dots-lod.js";
|
|
25
|
+
import { buildScene, takeoffsBy, firstLandings, flightPoint, easeInOut, replayClock, focusRect, cardsReadable, BOX } from "./dots-scene.js";
|
|
26
|
+
import { cardMorph, discMorph, discRadius, levelOf, caption, railMarks, railPos, lerp, LOD, directorScale } from "./dots-lod.js";
|
|
27
27
|
import { perimeter, pointAt, nearestS, segment } from "./dots-border.js";
|
|
28
28
|
import { getTokens, onThemeChange, contrast, hexToOklch, oklchToHex } from "./theme.js";
|
|
29
29
|
import { LOOP, carveStory, beatAt, tipsBetween, directorFocus, shortName as shortOf, liveBeat, liveTipsBetween, liveEndTip, LIVE_HOLD_MS } from "./dots-kiosk.js";
|
|
@@ -31,6 +31,8 @@ import { liveShow, stampArrivals, showKey, currentMigration, boxName, playedCoun
|
|
|
31
31
|
import { provenanceText, migrationTool, stepMsFor } from "./tour-player.js";
|
|
32
32
|
import { tourNow, tourFocus, tourFx, fxKey, tourMessage } from "./dots-tour.js";
|
|
33
33
|
import { wallTicks, recordedLabel, recordedMarks, speedWords, skippedWords, clockWords, RECORDED_SPEEDS } from "./dots-timeline.js";
|
|
34
|
+
import { resourceLight, rootLight } from "./cone.js";
|
|
35
|
+
import { GRID, cardLabel, cardShape, cardText, cardTextAlpha, pickMark, cardsMark, cardsFrame, cardsEstate, middleCard, gridScale, gridSlots, cardSize, cardNeed, rosterLod, unitKeyOf, minViewWidth, tipSpot, CARD_TEXT } from "./dots-cards.js";
|
|
34
36
|
|
|
35
37
|
/** #715: how often the live layer asks for the carve. The route shares one read for 1.5 s while a migration runs. */
|
|
36
38
|
export const LIVE_POLL_MS = 2_000;
|
|
@@ -46,16 +48,92 @@ const RIPPLE_MS = 650;
|
|
|
46
48
|
const PULSE_MS = 520;
|
|
47
49
|
const DRAW_MS = 650;
|
|
48
50
|
const LINGER_MS = 2600;
|
|
51
|
+
/** A viewer's hand on the camera (a wheel, a pinch, a drag, a rail mark) holds the director and the tour off until this long after their last input. */
|
|
52
|
+
export const VIEWER_HOLD_MS = 8_000;
|
|
53
|
+
/**
|
|
54
|
+
* A small stage: a carve of at most `max` resources, on a layer that draws its own cards, is read at the Cards
|
|
55
|
+
* level. Each estate's box is laid out as its card grid, cells `cell` pitches high and `aspect` wide, in the
|
|
56
|
+
* stage's shape (web/dots-scene.js cardGridShape), and the director frames it at the zoom that fits, up to
|
|
57
|
+
* CARDS_FRAME_GROW past the legible card size (web/dots-lod.js directorScale). A bigger estate keeps the dots.
|
|
58
|
+
*/
|
|
59
|
+
export const SMALL_STAGE = { max: 40, cell: 6, aspect: GRID.aspect };
|
|
60
|
+
|
|
61
|
+
/** Whether the scene on stage is a small one: laid out as SMALL_STAGE's card grid (sceneFor). */
|
|
62
|
+
function smallStage() {
|
|
63
|
+
return !!(S && S.seedless && S.scene && S.scene.cardGrid);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The scene for a show: a small stage's card grid when the layer draws its own cards, the show is small, and its
|
|
68
|
+
* cards read on this stage at the widest shot (dots-scene.js cardsReadable); else the dots' own layout, as before.
|
|
69
|
+
*/
|
|
70
|
+
function sceneFor(show, opts, seedless) {
|
|
71
|
+
if (seedless && show.roster.length <= SMALL_STAGE.max && opts.stage) {
|
|
72
|
+
const sc = buildScene(show, { ...opts, cardGrid: SMALL_STAGE });
|
|
73
|
+
if (cardsReadable(sc, opts.stage, rosterNeed(show.roster))) return sc;
|
|
74
|
+
}
|
|
75
|
+
return buildScene(show, opts);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The card width a roster's names need (dots-cards.js cardNeed), measured before the layer has a canvas of its own. */
|
|
79
|
+
function rosterNeed(roster) {
|
|
80
|
+
if (typeof document === "undefined") return 0;
|
|
81
|
+
const cv = document.createElement("canvas").getContext("2d");
|
|
82
|
+
if (!cv) return 0;
|
|
83
|
+
const font = (S && S.font) || getComputedStyle(document.body).fontFamily || "sans-serif";
|
|
84
|
+
return cardNeed(roster.map((r) => cardLabel(r)), (txt, px, weight) => {
|
|
85
|
+
cv.font = `${weight} ${px}px ${font}`;
|
|
86
|
+
return cv.measureText(txt).width;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
49
89
|
|
|
50
90
|
export function dotsActive() {
|
|
51
91
|
return !!S;
|
|
52
92
|
}
|
|
53
93
|
|
|
94
|
+
/** Report minor 34: the cone plan's lights (web/cone.js coneLights), set by the frame while it draws a pull request's plan; null otherwise. Kept across a remount. */
|
|
95
|
+
let coneNow = null;
|
|
96
|
+
|
|
97
|
+
/** The frame's cone lights, or null: planned resources lit, the rest of their root dimmed, a root not planned dimmed. */
|
|
98
|
+
export function setDotsCone(lights) {
|
|
99
|
+
coneNow = lights || null;
|
|
100
|
+
if (S) S.dirty = true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Each box's root, from the carve's rosters (estates.json's `root`); an adopted stock root's box answers for its estate too. */
|
|
104
|
+
function rootsOfBoxes() {
|
|
105
|
+
const out = new Map();
|
|
106
|
+
const alias = new Map(((S.answer && S.answer.adopted) || []).map((a) => [a.to, a.from]));
|
|
107
|
+
for (const e of (S.answer && S.answer.estates) || []) {
|
|
108
|
+
if (!e.root) continue;
|
|
109
|
+
out.set(e.estate, e.root);
|
|
110
|
+
if (alias.has(e.estate)) out.set(alias.get(e.estate), e.root);
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A cone light's glow on a dot or a card: planned lit, a changed one ringed, the rest dimmed (cone.js resourceLight). */
|
|
116
|
+
export function coneGlow(light, colour) {
|
|
117
|
+
if (light === "changed") return { colour, a: 1, ring: true, dim: false };
|
|
118
|
+
if (light === "lit") return { colour, a: 0.85, ring: false, dim: false };
|
|
119
|
+
if (light === "dim") return { colour, a: 0, ring: false, dim: true };
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
54
123
|
/** How far past the fit the zoom may go out, as a multiple of the fit's width; null when not mounted. */
|
|
55
124
|
export function dotsZoomOutFactor() {
|
|
56
125
|
return S ? S.zoomOut : null;
|
|
57
126
|
}
|
|
58
127
|
|
|
128
|
+
/**
|
|
129
|
+
* How far in the zoom may go, as the narrowest viewBox width: a little past where the roster's cards are fully drawn,
|
|
130
|
+
* while the canvas draws them; null otherwise (the app's own limit holds).
|
|
131
|
+
*/
|
|
132
|
+
export function dotsMinViewWidth() {
|
|
133
|
+
if (!S || !S.own) return null;
|
|
134
|
+
return minViewWidth(paneRect().width, S.rc.w, S.need);
|
|
135
|
+
}
|
|
136
|
+
|
|
59
137
|
/** #715: whether the live carve's director holds the camera (a migration is running in the kiosk's frame). */
|
|
60
138
|
export function dotsCarving() {
|
|
61
139
|
return !!(S && S.live && S.carving);
|
|
@@ -86,6 +164,8 @@ function addStyle() {
|
|
|
86
164
|
const st = document.createElement("style");
|
|
87
165
|
st.textContent = `
|
|
88
166
|
.dots-on > svg { position: relative; z-index: 1; background: transparent; }
|
|
167
|
+
/* Once the cards are out of the paint a touch lands on the host: a pinch there is the camera's, never the page's zoom. */
|
|
168
|
+
.dots-on { touch-action: none; }
|
|
89
169
|
.dots-on > svg > rect[fill^="url(#pin-"] { display: none; }
|
|
90
170
|
.dots-on > svg [data-node-id], .dots-on > svg rect[data-group-id], .dots-on > svg text { opacity: var(--dots-card-a, 1); }
|
|
91
171
|
#dots-canvas { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
|
|
@@ -100,6 +180,8 @@ function addStyle() {
|
|
|
100
180
|
.dots-rail-mark small { display: block; color: var(--muted); font-size: 11.5px; }
|
|
101
181
|
.dots-rail-mark i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--muted); background: var(--bg); flex: none; margin-right: 4px; }
|
|
102
182
|
.dots-rail-mark:hover i, .dots-rail-mark:focus-visible i { border-color: var(--focus); }
|
|
183
|
+
.dots-rail-mark:disabled { cursor: default; color: var(--muted); }
|
|
184
|
+
.dots-rail-mark:disabled:hover i { border-color: var(--muted); }
|
|
103
185
|
.dots-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: calc(100% - 24px); pointer-events: none; }
|
|
104
186
|
.dots-bottom > * { pointer-events: auto; }
|
|
105
187
|
.dots-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: calc(100% - 24px); background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; box-sizing: border-box; }
|
|
@@ -116,6 +198,8 @@ function addStyle() {
|
|
|
116
198
|
.dots-keep-bar .dots-bar { opacity: 0.55; transition: opacity 0.2s; }
|
|
117
199
|
.dots-rail { transition: opacity 0.4s; }
|
|
118
200
|
.dots-directing .dots-rail { opacity: 0; pointer-events: none; }
|
|
201
|
+
/* The kiosk's Watch holds one framing of a small stage (web/app.js kioskShotBox): no zoom to pick, and the docked column sits where the rail would. */
|
|
202
|
+
html.kiosk-held .dots-rail { opacity: 0; pointer-events: none; }
|
|
119
203
|
.dots-keep-bar .dots-bar:hover, .dots-keep-bar .dots-bar:focus-within { opacity: 1; }
|
|
120
204
|
/* In Watch the director holds the camera; the rail is Inspect's. */
|
|
121
205
|
.dots-kiosk.dots-watch:not(.dots-keep-bar) .dots-rail { display: none; }
|
|
@@ -261,10 +345,13 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
261
345
|
// carve's cards are the served roots' (`<member>/<address>`), joined by address.
|
|
262
346
|
const cards = new Map();
|
|
263
347
|
const widths = [];
|
|
348
|
+
// The cards the SVG draws of its own: what the card level shows when none of them is a resource's.
|
|
349
|
+
let svgCards = 0;
|
|
264
350
|
for (const g of svg.querySelectorAll("[data-node-id]")) {
|
|
265
351
|
const id = g.getAttribute("data-node-id");
|
|
266
352
|
const r = g.querySelector("rect");
|
|
267
353
|
if (!r) continue;
|
|
354
|
+
svgCards++;
|
|
268
355
|
const slash = id.indexOf("/");
|
|
269
356
|
if (live ? slash < 0 : !id.startsWith(prefix)) continue;
|
|
270
357
|
const addr = live ? id.slice(slash + 1) : id.slice(prefix.length);
|
|
@@ -278,12 +365,16 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
278
365
|
}
|
|
279
366
|
widths.sort((a, b) => a - b);
|
|
280
367
|
const cardW = widths[widths.length >> 1] || 200;
|
|
368
|
+
// A small live stage reads as the roster's own cards in their estates' boxes, whichever view is served under it:
|
|
369
|
+
// a team repo's view (the team beat) draws its roots' resources as cards of its own, which would otherwise be the
|
|
370
|
+
// card level, at their places on the page, and the director would keep the stage at the dots. They keep the pitch.
|
|
371
|
+
if (live && show.roster.length <= SMALL_STAGE.max) cards.clear();
|
|
281
372
|
const boxEl = svg.querySelector(`rect[data-group-id="${CSS.escape(show.source)}"]`) || svg.querySelector("rect[data-group-id]");
|
|
282
373
|
const mbox = boxEl
|
|
283
374
|
? { x: +boxEl.getAttribute("x"), y: +boxEl.getAttribute("y"), w: +boxEl.getAttribute("width"), h: +boxEl.getAttribute("height") }
|
|
284
375
|
: { x: vbInit[0], y: vbInit[1], w: vbInit[2], h: vbInit[3] };
|
|
285
376
|
// The source estate's box takes its cards' box's place and shape on the page.
|
|
286
|
-
const scene =
|
|
377
|
+
const scene = sceneFor(show, { sourceAspect: mbox.w / Math.max(1, mbox.h), ...labelRoom(host) }, cards.size === 0);
|
|
287
378
|
const src = scene.sourceBox;
|
|
288
379
|
// One dot pitch is a fixed share of a card's width, so a dot is legible exactly
|
|
289
380
|
// when its card stops being: at the dot size a pitch is about 8 px, whatever
|
|
@@ -315,6 +406,20 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
315
406
|
cards,
|
|
316
407
|
cardW,
|
|
317
408
|
pitch,
|
|
409
|
+
// No SVG card is a resource's (a live carve at the Components zoom draws one per root): the canvas draws the roster's.
|
|
410
|
+
seedless: cards.size === 0,
|
|
411
|
+
svgCards,
|
|
412
|
+
// The roster's cards (fitRosterCards): their size in viewBox units, the width in px their card level starts at.
|
|
413
|
+
rc: { w: 1, h: 1 },
|
|
414
|
+
need: LOD.cardPx,
|
|
415
|
+
lodR: LOD,
|
|
416
|
+
gridK: 0,
|
|
417
|
+
grids: new WeakMap(),
|
|
418
|
+
gdisp: new Map(),
|
|
419
|
+
ownA: 0,
|
|
420
|
+
own: false,
|
|
421
|
+
labels: new Map(),
|
|
422
|
+
fits: new Map(),
|
|
318
423
|
origin,
|
|
319
424
|
mbox,
|
|
320
425
|
live: !!live,
|
|
@@ -343,6 +448,8 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
343
448
|
px: new Float32Array(n),
|
|
344
449
|
py: new Float32Array(n),
|
|
345
450
|
pvis: new Uint8Array(n),
|
|
451
|
+
pw: new Float32Array(n),
|
|
452
|
+
ph: new Float32Array(n),
|
|
346
453
|
stats: { draw: [], frame: [] },
|
|
347
454
|
snap: true,
|
|
348
455
|
fly: null,
|
|
@@ -353,6 +460,7 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
353
460
|
S.col = readColours();
|
|
354
461
|
// The page's own UI face; a canvas cannot read var() in its font.
|
|
355
462
|
S.font = (cssVar("--font-ui") || "system-ui, sans-serif").replace(/;$/, "");
|
|
463
|
+
fitRosterCards();
|
|
356
464
|
S.off.push(onThemeChange(() => {
|
|
357
465
|
if (!S) return;
|
|
358
466
|
S.col = readColours();
|
|
@@ -439,7 +547,7 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
439
547
|
const setInsets = (ins) => {
|
|
440
548
|
if (S) S.insets = { top: Number(ins.top) || 0, bottom: Number(ins.bottom) || 0 };
|
|
441
549
|
};
|
|
442
|
-
window.__dots = { select: (id) => selectDot(id), landed: () => S && landedIds(), seek, play, step, zoomTo, zoomCardPx, setInsets, pause: () => play(false), fly, setSpeed, stats: () => S && S.stats, length: () => S && S.clock.length, marks: () => S && currentMarks(), state: () => S && { t: S.t, level: S.level, reduced: S.reduced, cardPx: S.cardPx, pitchPx: S.pitchPx }, debug: () => S && { band: (({ left, right, w }) => ({ left, right, w }))(band()), svg: S.svg.getBoundingClientRect().toJSON(), rail: S.ui.querySelector('.dots-rail').getBoundingClientRect().toJSON(), vb: S.getVB(), dir: S.dir, directing: S.directing, focusBox: S.dir && focusBox(S.dir.focus), want: S.dir && frameBox(focusBox(S.dir.focus)), pitch: S.pitch, origin: S.origin }, story: () => S && S.story && { start: S.story.start, end: S.story.end, firstRefusal: S.story.firstRefusal ? S.story.firstRefusal.end : null } };
|
|
550
|
+
window.__dots = { cone: () => S && S.coneShown, select: (id) => selectDot(id), landed: () => S && landedIds(), seek, play, step, zoomTo, zoomCardPx, setInsets, pause: () => play(false), fly, setSpeed, stats: () => S && S.stats, length: () => S && S.clock.length, marks: () => S && currentMarks(), state: () => S && { t: S.t, level: S.level, reduced: S.reduced, cardPx: S.cardPx, pitchPx: S.pitchPx, rosterCards: S.own, rosterCardPx: S.rosterCardPx, directing: !!S.directing }, debug: () => S && { band: (({ left, right, w }) => ({ left, right, w }))(band()), svg: S.svg.getBoundingClientRect().toJSON(), rail: S.ui.querySelector('.dots-rail').getBoundingClientRect().toJSON(), vb: S.getVB(), dir: S.dir, directing: S.directing, focusBox: S.dir && focusBox(S.dir.focus), want: S.dir && frameBox(focusBox(S.dir.focus)), pitch: S.pitch, origin: S.origin, frame: S.frameNums || null, smallStage: smallStage(), roster: S.show.roster.length }, story: () => S && S.story && { start: S.story.start, end: S.story.end, firstRefusal: S.story.firstRefusal ? S.story.firstRefusal.end : null } };
|
|
443
551
|
const loop = (wall) => {
|
|
444
552
|
if (!S) return;
|
|
445
553
|
S.raf = requestAnimationFrame(loop);
|
|
@@ -523,6 +631,8 @@ function labelRoom(host) {
|
|
|
523
631
|
labelPx: (e) => cv.measureText(`${e} 000`).width + 12,
|
|
524
632
|
labelH: 18,
|
|
525
633
|
avail: { w: r.width * 0.72, h: Math.max(80, r.height - (ins.top || 0) - (ins.bottom || 0) - 32) },
|
|
634
|
+
// The stage the director frames in: the pane less the zoom rail's band and its margins, clear of the caption.
|
|
635
|
+
stage: { w: Math.max(40, r.width - 182), h: Math.max(40, r.height - (ins.top || 0) - (ins.bottom || 0) - 16) },
|
|
526
636
|
};
|
|
527
637
|
}
|
|
528
638
|
|
|
@@ -570,7 +680,8 @@ function currentMarks() {
|
|
|
570
680
|
const sorted = [...sizes].sort((a, b) => a - b);
|
|
571
681
|
const typical = sorted.length ? sorted[sorted.length >> 1] : 0;
|
|
572
682
|
const P = S.pitch;
|
|
573
|
-
|
|
683
|
+
// The card level is where the cards that draw are legible: the roster's own when the canvas draws them.
|
|
684
|
+
return railMarks({ paneW: bw, paneH: r.height || 1, cardW: S.own ? S.rc.w : S.cardW, ...(S.own ? { lod: S.lodR, cardAt: S.need * 1.1 } : {}), sceneW: S.scene.extent.w * P, sceneH: S.scene.extent.h * P, smallestBox: Number.isFinite(small) ? small * P : 0, largestBox: big * P, typicalBox: typical * P });
|
|
574
685
|
}
|
|
575
686
|
|
|
576
687
|
/** Fly the camera to a rail mark, centred on the scene (or the cards for Cards). */
|
|
@@ -582,6 +693,25 @@ function fly(mark) {
|
|
|
582
693
|
const vb = S.getVB();
|
|
583
694
|
const ext = S.scene.extent;
|
|
584
695
|
const P = S.pitch;
|
|
696
|
+
if (mark === "cards" && S.own) {
|
|
697
|
+
// The roster's cards: the one nearest the middle of the director's estate's cards, else the source estate's, else
|
|
698
|
+
// the fullest estate's, at the width where a card is just fully drawn.
|
|
699
|
+
const sc = S.scene;
|
|
700
|
+
const L = sc.layoutAt(takeoffsBy(sc, S.t));
|
|
701
|
+
const grid = gridOf(L);
|
|
702
|
+
const counts = new Map();
|
|
703
|
+
for (const a of grid.keys()) counts.set(L.owners.get(a), (counts.get(L.owners.get(a)) ?? 0) + 1);
|
|
704
|
+
const f = S.dir && S.dir.focus;
|
|
705
|
+
const e = cardsEstate(f && f.kind === "estate" ? f.estate : null, sc.source, counts);
|
|
706
|
+
const at = e === null ? null : middleCard([...grid].filter(([a]) => L.owners.get(a) === e).map(([, p]) => p));
|
|
707
|
+
if (!at) return;
|
|
708
|
+
const { r, left, right } = band();
|
|
709
|
+
const to = cardsFrame({ x: S.origin.x + at.x * P, y: S.origin.y + at.y * P }, w, vb[3] / vb[2]);
|
|
710
|
+
to[0] -= (((left - right) / 2) * w) / Math.max(1, r.width);
|
|
711
|
+
if (S.reduced) S.setVB(to);
|
|
712
|
+
else S.fly = { from: vb.slice(), to, start: performance.now(), dur: 900 };
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
585
715
|
const cx = mark === "cards" ? Math.max(S.origin.x + w / 2, Math.min(vb[0] + vb[2] / 2, S.origin.x + S.scene.sourceBox.w * P - w / 2)) : S.origin.x + (ext.w * P) / 2;
|
|
586
716
|
const cy = mark === "cards" ? Math.max(S.origin.y + (w * vb[3]) / vb[2] / 2, Math.min(vb[1] + vb[3] / 2, S.origin.y + S.scene.sourceBox.h * P)) : S.origin.y + (ext.h * P) / 2;
|
|
587
717
|
// Centre in the part of the pane the floating panel leaves uncovered.
|
|
@@ -644,6 +774,8 @@ function buildUi() {
|
|
|
644
774
|
b.title = `Fly to ${label.toLowerCase()}`;
|
|
645
775
|
b.addEventListener("click", (e) => {
|
|
646
776
|
e.stopPropagation();
|
|
777
|
+
// A mark is a viewer's hand on the camera: the director waits while it flies and reads.
|
|
778
|
+
viewerHold();
|
|
647
779
|
fly(k);
|
|
648
780
|
});
|
|
649
781
|
b.addEventListener("mousedown", (e) => e.stopPropagation());
|
|
@@ -813,7 +945,13 @@ function updateUiFrame(counts, level) {
|
|
|
813
945
|
const marks = currentMarks();
|
|
814
946
|
// The zoom goes out a little past the estates mark and no further.
|
|
815
947
|
S.zoomOut = Math.max(3, (marks.estates * 1.4) / Math.max(1, S.vbInit[2]));
|
|
816
|
-
|
|
948
|
+
// The Cards mark counts the cards that can draw at its zoom, never more.
|
|
949
|
+
const cm = cardsMark({ resources: S.show.roster.length, seeded: S.cards.size, svgCards: S.svgCards, own: S.own });
|
|
950
|
+
if (S.railMarks.cards.disabled === cm.enabled) {
|
|
951
|
+
S.railMarks.cards.disabled = !cm.enabled;
|
|
952
|
+
S.railMarks.cards.title = cm.enabled ? "Fly to cards" : "No cards draw here";
|
|
953
|
+
}
|
|
954
|
+
const sub = { cards: cm.words, resources: `${fmt(S.show.roster.length)} resources`, estates: `${estatesNow} estate${estatesNow === 1 ? "" : "s"}` };
|
|
817
955
|
for (const k of Object.keys(S.railMarks)) {
|
|
818
956
|
const sm = S.railMarks[k].querySelector("small");
|
|
819
957
|
if (sm.textContent !== sub[k]) sm.textContent = sub[k];
|
|
@@ -834,21 +972,13 @@ function hoverAt(e) {
|
|
|
834
972
|
S.tip.style.display = "none";
|
|
835
973
|
return;
|
|
836
974
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
for (let i = 0; i < S.addrs.length; i++) {
|
|
840
|
-
if (!S.pvis[i]) continue;
|
|
841
|
-
const d = (S.px[i] - x) ** 2 + (S.py[i] - y) ** 2;
|
|
842
|
-
if (d < bd) {
|
|
843
|
-
bd = d;
|
|
844
|
-
best = i;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
975
|
+
// A roster card is hit anywhere on it; a dot within 10 px of its centre.
|
|
976
|
+
const best = pickMark(x, y, S, { within: 10 });
|
|
847
977
|
if (best < 0) {
|
|
848
978
|
S.tip.style.display = "none";
|
|
849
979
|
return;
|
|
850
980
|
}
|
|
851
|
-
showTip(S.addrs[best], x, y);
|
|
981
|
+
showTip(S.addrs[best], x, S.ph[best] > 0 ? S.py[best] + S.ph[best] : y, S.ph[best] > 0 ? S.py[best] - S.ph[best] : y);
|
|
852
982
|
}
|
|
853
983
|
|
|
854
984
|
/** A landed dot's provenance: what its newest write was, from its progress line and the migration's run; null for a dot no line names. */
|
|
@@ -878,7 +1008,7 @@ function recordedProvenance(id) {
|
|
|
878
1008
|
return { text: `${text} · ${file}${best.line ? ` line ${best.line}` : ""}`, url: null, seek: best.t };
|
|
879
1009
|
}
|
|
880
1010
|
|
|
881
|
-
function showTip(a, x, y) {
|
|
1011
|
+
function showTip(a, x, y, top = y) {
|
|
882
1012
|
const prov = provenanceOf(a);
|
|
883
1013
|
S.tip.replaceChildren(el("div", "", `${a} · ${shortName(S.ownersNow.get(a) ?? S.scene.source)}`));
|
|
884
1014
|
if (prov) {
|
|
@@ -890,8 +1020,10 @@ function showTip(a, x, y) {
|
|
|
890
1020
|
S.tip.classList.toggle("dots-tip-go", !!(prov && prov.seek !== undefined && S.selected === a));
|
|
891
1021
|
S.tipSeek = prov && prov.seek !== undefined ? prov.seek : null;
|
|
892
1022
|
S.tip.style.display = "block";
|
|
893
|
-
|
|
894
|
-
S.tip.
|
|
1023
|
+
// Clear of the rail on the right, and over the mark when the pane's foot leaves no room under it.
|
|
1024
|
+
const spot = tipSpot(x, y, { tipW: S.tip.offsetWidth, tipH: S.tip.offsetHeight, paneW: S.host.clientWidth, paneH: S.host.clientHeight, rightInset: band().right, above: top });
|
|
1025
|
+
S.tip.style.left = `${spot.left}px`;
|
|
1026
|
+
S.tip.style.top = `${spot.top}px`;
|
|
895
1027
|
}
|
|
896
1028
|
|
|
897
1029
|
/** The dots that a write of this cycle landed, in the order they were written: what the keys step through. */
|
|
@@ -922,7 +1054,7 @@ function selectDot(id) {
|
|
|
922
1054
|
S.provLink.hidden = !(prov && prov.url);
|
|
923
1055
|
if (prov && prov.url) S.provLink.href = prov.url;
|
|
924
1056
|
}
|
|
925
|
-
if (i !== undefined && S.pvis[i]) showTip(id, S.px[i], S.py[i]);
|
|
1057
|
+
if (i !== undefined && S.pvis[i]) showTip(id, S.px[i], S.py[i] + S.ph[i], S.py[i] - S.ph[i]);
|
|
926
1058
|
S.dirty = true;
|
|
927
1059
|
}
|
|
928
1060
|
|
|
@@ -930,17 +1062,8 @@ function nearestDot(e, within = 100) {
|
|
|
930
1062
|
const hr = S.host.getBoundingClientRect();
|
|
931
1063
|
const x = e.clientX - hr.left + S.host.scrollLeft;
|
|
932
1064
|
const y = e.clientY - hr.top + S.host.scrollTop;
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
for (let i = 0; i < S.addrs.length; i++) {
|
|
936
|
-
if (!S.pvis[i]) continue;
|
|
937
|
-
const d = (S.px[i] - x) ** 2 + (S.py[i] - y) ** 2;
|
|
938
|
-
if (d < bd) {
|
|
939
|
-
bd = d;
|
|
940
|
-
best = i;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
return best;
|
|
1065
|
+
// `within` is a squared distance, as it always was here.
|
|
1066
|
+
return pickMark(x, y, S, { within: Math.sqrt(within) });
|
|
944
1067
|
}
|
|
945
1068
|
|
|
946
1069
|
// --- drawing -----------------------------------------------------------------
|
|
@@ -968,6 +1091,185 @@ function roundRect(ctx, x, y, w, h, r) {
|
|
|
968
1091
|
else ctx.rect(x, y, w, h);
|
|
969
1092
|
}
|
|
970
1093
|
|
|
1094
|
+
/**
|
|
1095
|
+
* The roster's cards for the scene now: one cell size every estate's grid fits at across the show (sampled at its
|
|
1096
|
+
* start, its end and 39 moments between), the card size and the width in px at which a card is fully drawn: wide
|
|
1097
|
+
* enough for the longest name and type. Only a scene with no SVG card for any resource draws them.
|
|
1098
|
+
*/
|
|
1099
|
+
function fitRosterCards() {
|
|
1100
|
+
S.grids = new WeakMap();
|
|
1101
|
+
S.gdisp = new Map();
|
|
1102
|
+
S.labels.clear();
|
|
1103
|
+
S.fits.clear();
|
|
1104
|
+
if (!S.seedless) return;
|
|
1105
|
+
const sc = S.scene;
|
|
1106
|
+
S.unitKey = unitKeyOf(sc.rosterBy);
|
|
1107
|
+
const n = sc.landing.length;
|
|
1108
|
+
const ks = new Set([0, n]);
|
|
1109
|
+
for (let j = 1; j < 40; j++) ks.add(Math.round((n * j) / 40));
|
|
1110
|
+
S.gridK = gridScale([...ks].map((k) => sc.layoutAt(k)), S.unitKey, smallStage() ? { maxK: SMALL_STAGE.cell } : {});
|
|
1111
|
+
const c = cardSize(S.gridK);
|
|
1112
|
+
S.rc = { w: c.w * S.pitch, h: c.h * S.pitch };
|
|
1113
|
+
const ctx = S.ctx;
|
|
1114
|
+
S.need = cardNeed(
|
|
1115
|
+
S.show.roster.map((r) => labelOf(r.address)),
|
|
1116
|
+
(txt, px, weight) => {
|
|
1117
|
+
ctx.font = `${weight} ${px}px ${S.font}`;
|
|
1118
|
+
return ctx.measureText(txt).width;
|
|
1119
|
+
},
|
|
1120
|
+
);
|
|
1121
|
+
S.lodR = rosterLod(S.need);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/** Each roster card's cell in a layout, in pitches (web/dots-cards.js gridSlots), kept per layout. */
|
|
1125
|
+
function gridOf(layout) {
|
|
1126
|
+
let g = S.grids.get(layout);
|
|
1127
|
+
if (!g) {
|
|
1128
|
+
g = gridSlots(layout, S.gridK, S.unitKey);
|
|
1129
|
+
S.grids.set(layout, g);
|
|
1130
|
+
}
|
|
1131
|
+
return g;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Where a resource's card is now, in pitches: flying from its cell in the box it leaves to its cell in the box it
|
|
1136
|
+
* lands in, or at rest in its cell, sliding when a box re-packs as its dots do.
|
|
1137
|
+
*/
|
|
1138
|
+
function cellOf(a, f, L, t, ease) {
|
|
1139
|
+
if (f && f.ok) {
|
|
1140
|
+
const from = gridOf(S.scene.layoutAt(f.k - 1)).get(a);
|
|
1141
|
+
const to = gridOf(S.scene.layoutAt(f.k)).get(a) ?? from;
|
|
1142
|
+
if (!from) return to ?? null;
|
|
1143
|
+
const uf = (t - f.start) / (f.end - f.start);
|
|
1144
|
+
if (S.reduced) return uf < 0.5 ? from : to;
|
|
1145
|
+
S.cellMoving = true;
|
|
1146
|
+
return flightPoint(from, to, uf);
|
|
1147
|
+
}
|
|
1148
|
+
const target = gridOf(L).get(a);
|
|
1149
|
+
if (!target) return null;
|
|
1150
|
+
const prev = S.gdisp.get(a);
|
|
1151
|
+
const out = prev && !S.snap && ease < 1 ? { x: lerp(prev.x, target.x, ease), y: lerp(prev.y, target.y, ease) } : target;
|
|
1152
|
+
if (Math.abs(out.x - target.x) + Math.abs(out.y - target.y) > 0.01) S.cellMoving = true;
|
|
1153
|
+
S.gdisp.set(a, out);
|
|
1154
|
+
return out;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/** A roster row's card words, from its address and type alone (web/dots-cards.js). */
|
|
1158
|
+
function labelOf(a) {
|
|
1159
|
+
let l = S.labels.get(a);
|
|
1160
|
+
if (!l) {
|
|
1161
|
+
l = cardLabel(S.scene.rosterBy.get(a) || { address: a });
|
|
1162
|
+
S.labels.set(a, l);
|
|
1163
|
+
}
|
|
1164
|
+
return l;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/** A card's lines at its size now, kept by size: fitting a name measures it several times. */
|
|
1168
|
+
function linesOf(ctx, a, sh) {
|
|
1169
|
+
const key = `${a}|${Math.round(sh.w)}|${Math.round(sh.h)}`;
|
|
1170
|
+
let lines = S.fits.get(key);
|
|
1171
|
+
if (!lines) {
|
|
1172
|
+
lines = cardText(labelOf(a), { w: sh.w, h: sh.h, need: S.need }, (txt, px, weight) => {
|
|
1173
|
+
ctx.font = `${weight} ${px}px ${S.font}`;
|
|
1174
|
+
return ctx.measureText(txt).width;
|
|
1175
|
+
});
|
|
1176
|
+
if (S.fits.size > 4000) S.fits.clear();
|
|
1177
|
+
S.fits.set(key, lines);
|
|
1178
|
+
}
|
|
1179
|
+
return lines;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* A resource's roster card, `u` of the way from its dot (0) to its card (1): the dot's disc grows into a rounded
|
|
1184
|
+
* rect in its estate's colour, which pales to a tint on the page's surface as the name and the type fade in. The
|
|
1185
|
+
* marks a dot wears (a tour's light, the adoption's ring, the selection, a takeoff) go round the card.
|
|
1186
|
+
*/
|
|
1187
|
+
function drawRosterCard(ctx, a, sh, u, { vis: vis0, colour, glow, ring, selected, takeoff }) {
|
|
1188
|
+
const col = S.col;
|
|
1189
|
+
const round = (o) => roundRect(ctx, sh.x - o, sh.y - o, sh.w + 2 * o, sh.h + 2 * o, sh.r + o);
|
|
1190
|
+
// A card the plan planned but does not change steps back beside the one it changes.
|
|
1191
|
+
const vis = glow && glow.dim ? vis0 * 0.55 : vis0;
|
|
1192
|
+
if (glow) {
|
|
1193
|
+
ctx.globalAlpha = vis * glow.a * (glow.ring ? 1 : 0.7);
|
|
1194
|
+
ctx.strokeStyle = glow.colour;
|
|
1195
|
+
ctx.lineWidth = glow.ring ? 4.5 : 3;
|
|
1196
|
+
round(glow.ring ? 4 : 3);
|
|
1197
|
+
ctx.stroke();
|
|
1198
|
+
}
|
|
1199
|
+
round(0);
|
|
1200
|
+
ctx.globalAlpha = vis * Math.min(1, u * 2);
|
|
1201
|
+
ctx.fillStyle = col.surface || col.bg;
|
|
1202
|
+
ctx.fill();
|
|
1203
|
+
ctx.globalAlpha = vis * lerp(1, 0.12, u);
|
|
1204
|
+
ctx.fillStyle = colour;
|
|
1205
|
+
ctx.fill();
|
|
1206
|
+
ctx.globalAlpha = vis * Math.min(1, u * 1.5);
|
|
1207
|
+
ctx.strokeStyle = colour;
|
|
1208
|
+
ctx.lineWidth = 1.2;
|
|
1209
|
+
ctx.stroke();
|
|
1210
|
+
const ta = cardTextAlpha(u);
|
|
1211
|
+
if (u > 0.5) {
|
|
1212
|
+
ctx.save();
|
|
1213
|
+
round(0);
|
|
1214
|
+
ctx.clip();
|
|
1215
|
+
ctx.globalAlpha = vis;
|
|
1216
|
+
ctx.fillStyle = colour;
|
|
1217
|
+
ctx.fillRect(sh.x, sh.y, CARD_TEXT.bar, sh.h);
|
|
1218
|
+
const lines = ta > 0 ? linesOf(ctx, a, sh) : [];
|
|
1219
|
+
if (lines.length) {
|
|
1220
|
+
const total = lines.reduce((n, l) => n + l.size * 1.25, 0);
|
|
1221
|
+
let y = sh.y + (sh.h - total) / 2;
|
|
1222
|
+
ctx.textAlign = "left";
|
|
1223
|
+
ctx.textBaseline = "middle";
|
|
1224
|
+
ctx.globalAlpha = vis * ta;
|
|
1225
|
+
for (const l of lines) {
|
|
1226
|
+
ctx.font = `${l.weight} ${l.size}px ${S.font}`;
|
|
1227
|
+
ctx.fillStyle = l.ink === "muted" ? col.muted : col.fg;
|
|
1228
|
+
ctx.fillText(l.text, sh.x + CARD_TEXT.bar + CARD_TEXT.pad, y + l.size * 0.625);
|
|
1229
|
+
y += l.size * 1.25;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
ctx.restore();
|
|
1233
|
+
}
|
|
1234
|
+
if (ring) {
|
|
1235
|
+
// It wears its estate's tags now: a ring round the dot, a tag on the card's corner.
|
|
1236
|
+
ctx.globalAlpha = vis;
|
|
1237
|
+
if (u < 0.5) {
|
|
1238
|
+
ctx.strokeStyle = col.managed;
|
|
1239
|
+
ctx.lineWidth = 1.2;
|
|
1240
|
+
round(2);
|
|
1241
|
+
ctx.stroke();
|
|
1242
|
+
} else {
|
|
1243
|
+
ctx.fillStyle = col.managed;
|
|
1244
|
+
ctx.beginPath();
|
|
1245
|
+
ctx.arc(sh.x + sh.w - 6, sh.y + 6, Math.max(2, Math.min(3.5, sh.h * 0.08)), 0, Math.PI * 2);
|
|
1246
|
+
ctx.fill();
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
if (glow && glow.ring) {
|
|
1250
|
+
ctx.globalAlpha = vis;
|
|
1251
|
+
ctx.strokeStyle = glow.colour;
|
|
1252
|
+
ctx.lineWidth = 2;
|
|
1253
|
+
round(5);
|
|
1254
|
+
ctx.stroke();
|
|
1255
|
+
}
|
|
1256
|
+
if (selected) {
|
|
1257
|
+
ctx.globalAlpha = 1;
|
|
1258
|
+
ctx.strokeStyle = col.fg;
|
|
1259
|
+
ctx.lineWidth = 1.6;
|
|
1260
|
+
round(4);
|
|
1261
|
+
ctx.stroke();
|
|
1262
|
+
}
|
|
1263
|
+
if (takeoff < 0.2) {
|
|
1264
|
+
ctx.globalAlpha = vis * (1 - takeoff / 0.2);
|
|
1265
|
+
ctx.strokeStyle = col.pending;
|
|
1266
|
+
ctx.lineWidth = 1.4;
|
|
1267
|
+
round(2 + takeoff * 20);
|
|
1268
|
+
ctx.stroke();
|
|
1269
|
+
}
|
|
1270
|
+
ctx.globalAlpha = 1;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
971
1273
|
function polyline(ctx, pts) {
|
|
972
1274
|
if (pts.length < 2) return;
|
|
973
1275
|
ctx.beginPath();
|
|
@@ -1005,11 +1307,25 @@ function draw(dt) {
|
|
|
1005
1307
|
const tc = cardMorph(S.cardW * s, { reduced });
|
|
1006
1308
|
S.cardPx = S.cardW * s;
|
|
1007
1309
|
S.pitchPx = P * s;
|
|
1008
|
-
|
|
1310
|
+
// With no SVG card for any resource, the canvas draws the roster's cards: while the carve holds the stage (a live
|
|
1311
|
+
// carve's director or tour), or always for a recording. The SVG's own cards (a live carve's roots) stay out of the
|
|
1312
|
+
// paint then, and come back, eased, when the stage is theirs again.
|
|
1313
|
+
const ownWant = S.seedless && (!S.live || S.carving) ? 1 : 0;
|
|
1314
|
+
S.ownA = S.snap || reduced ? ownWant : lerp(S.ownA, ownWant, 1 - Math.exp(-dt / 300));
|
|
1315
|
+
if (Math.abs(S.ownA - ownWant) < 0.01) S.ownA = ownWant;
|
|
1316
|
+
const ownA = S.ownA;
|
|
1317
|
+
S.own = ownA >= 0.5;
|
|
1318
|
+
// The roster's cards grow from the dots in their slots: their own size on screen picks their form, as a card's does.
|
|
1319
|
+
const rcW = S.rc.w * s;
|
|
1320
|
+
const rcH = S.rc.h * s;
|
|
1321
|
+
S.rosterCardPx = rcW;
|
|
1322
|
+
const tr = cardMorph(rcW, { reduced, lod: S.lodR });
|
|
1323
|
+
const layerA = lerp(tc, 1, ownA);
|
|
1324
|
+
S.cardA = 1 - layerA;
|
|
1009
1325
|
// Cards fade faster than the dots grow, so the dots under them read by the middle of the morph.
|
|
1010
|
-
const cardA = Math.pow(1 - tc, 2).toFixed(3);
|
|
1326
|
+
const cardA = (Math.pow(1 - tc, 2) * (1 - ownA)).toFixed(3);
|
|
1011
1327
|
if (S.host.style.getPropertyValue("--dots-card-a") !== cardA) S.host.style.setProperty("--dots-card-a", cardA);
|
|
1012
|
-
const hide = tc >= 1;
|
|
1328
|
+
const hide = tc >= 1 || ownA >= 1;
|
|
1013
1329
|
if (hide !== S.svgHidden) {
|
|
1014
1330
|
// The export owns its camera and measures the host, so it takes the SVG out of
|
|
1015
1331
|
// layout altogether; the app's own wheel handler measures the SVG, so there it stays in layout.
|
|
@@ -1053,11 +1369,14 @@ function draw(dt) {
|
|
|
1053
1369
|
const size = Math.max(b.w, b.h, fin ? Math.max(fin.w, fin.h) : 0);
|
|
1054
1370
|
td.set(e, discMorph(size * P * s, { reduced }));
|
|
1055
1371
|
}
|
|
1056
|
-
const level = levelOf(tc, td.values());
|
|
1372
|
+
const level = levelOf(S.own ? tr : tc, td.values());
|
|
1057
1373
|
// Reaching the estate level by hand fits the estates, so they are not a speck in a corner.
|
|
1058
1374
|
if (level === "discs" && S.level && S.level !== "discs" && !S.fly && !S.directing) queueMicrotask(() => fly("estates"));
|
|
1059
1375
|
S.level = level;
|
|
1060
|
-
const dotLayerA =
|
|
1376
|
+
const dotLayerA = layerA;
|
|
1377
|
+
// How far a resource with no SVG card has grown into its roster card: 0 its dot, 1 its card.
|
|
1378
|
+
const rosterU = ownA * (1 - tr);
|
|
1379
|
+
if (ownA !== ownWant) moving = true;
|
|
1061
1380
|
|
|
1062
1381
|
// Activity per estate: dots in the air toward it (or leaving it), for the running light.
|
|
1063
1382
|
const act = new Map();
|
|
@@ -1095,8 +1414,11 @@ function draw(dt) {
|
|
|
1095
1414
|
const titlePx = BOX.title * P * s;
|
|
1096
1415
|
// Where each box's label went, so a Tips bubble keeps off it (web/carve-narration.js).
|
|
1097
1416
|
const labelPx = new Map();
|
|
1417
|
+
// Report minor 34: a box whose root the pull request did not plan, while a cone plan is drawn: dimmed, and said.
|
|
1418
|
+
const boxRoots = coneNow ? rootsOfBoxes() : null;
|
|
1419
|
+
const notPlanned = (e) => !!boxRoots && boxRoots.has(e) && rootLight(coneNow, boxRoots.get(e)) === "dim";
|
|
1098
1420
|
for (const [e, b] of boxes) {
|
|
1099
|
-
const a = dotLayerA * (1 - (td.get(e) ?? 0));
|
|
1421
|
+
const a = dotLayerA * (1 - (td.get(e) ?? 0)) * (notPlanned(e) ? 0.5 : 1);
|
|
1100
1422
|
if (a <= 0.01) continue;
|
|
1101
1423
|
const c = col.estate.get(e) || col.neutral;
|
|
1102
1424
|
const bp = boxPx(b);
|
|
@@ -1150,12 +1472,12 @@ function draw(dt) {
|
|
|
1150
1472
|
// and the box have room, else just above the outline (it may run past a
|
|
1151
1473
|
// narrow box's edge), so a label never sits on the dots.
|
|
1152
1474
|
const fs = 11.5;
|
|
1153
|
-
if (
|
|
1475
|
+
if (dotLayerA > 0.6 && (td.get(e) ?? 0) < 0.5) {
|
|
1154
1476
|
ctx.font = `700 ${fs}px ${S.font}`;
|
|
1155
1477
|
ctx.textBaseline = "middle";
|
|
1156
1478
|
ctx.textAlign = "left";
|
|
1157
1479
|
let nm = shortName(e);
|
|
1158
|
-
const cnt = fmt(Math.max(0, counts.get(e) ?? 0))
|
|
1480
|
+
const cnt = `${fmt(Math.max(0, counts.get(e) ?? 0))}${notPlanned(e) ? " · not planned" : ""}`;
|
|
1159
1481
|
let nw = ctx.measureText(nm).width;
|
|
1160
1482
|
const cw = ctx.measureText(cnt).width;
|
|
1161
1483
|
const tw = nw + fs * 0.5 + cw;
|
|
@@ -1258,13 +1580,33 @@ function draw(dt) {
|
|
|
1258
1580
|
}
|
|
1259
1581
|
// The tour's lights: each resource the chapter's plan planned, brighter where the plan changes it.
|
|
1260
1582
|
const fx = currentFx(owners);
|
|
1583
|
+
// A plan that changes some of what it planned (the team beat: one inline policy of team B's five resources) lights
|
|
1584
|
+
// the changed cards and dims the rest, so "only this changes" reads on the cards.
|
|
1585
|
+
const anyChanged = !!fx && [...fx.lights.values()].some((l) => l.changed);
|
|
1261
1586
|
if (fx) for (const [id, l] of fx.lights) {
|
|
1262
1587
|
const prev = glow.get(id);
|
|
1263
|
-
const g =
|
|
1588
|
+
const g = tourGlow(l, anyChanged, col.foreign);
|
|
1264
1589
|
if (!prev || g.a >= prev.a) glow.set(id, g);
|
|
1265
1590
|
}
|
|
1591
|
+
// Report minor 34: a cone plan's lights, from the frame (setDotsCone). Planned resources lit, the rest dimmed, never hidden.
|
|
1592
|
+
const coneShown = coneNow ? { lit: [], changed: [], dim: [], notPlanned: [] } : null;
|
|
1593
|
+
if (coneNow) {
|
|
1594
|
+
const rootOfBox = rootsOfBoxes();
|
|
1595
|
+
for (const [e, root] of rootOfBox) if (rootLight(coneNow, root) === "dim" && boxes.has(e)) coneShown.notPlanned.push(e);
|
|
1596
|
+
for (const a of addrs) {
|
|
1597
|
+
const root = rootOfBox.get(owners.get(a) ?? scene.source);
|
|
1598
|
+
const light = root ? resourceLight(coneNow, root, a.replace(/#\d+$/, "")) : null;
|
|
1599
|
+
const g = coneGlow(light, col.pending);
|
|
1600
|
+
if (!g) continue;
|
|
1601
|
+
coneShown[light === "changed" ? "changed" : light].push(a);
|
|
1602
|
+
const prev = glow.get(a);
|
|
1603
|
+
if (!prev || g.a >= prev.a) glow.set(a, g);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
S.coneShown = coneShown;
|
|
1266
1607
|
ctx.globalAlpha = 1;
|
|
1267
1608
|
const refusedLit = [];
|
|
1609
|
+
S.cellMoving = false;
|
|
1268
1610
|
for (let i = 0; i < addrs.length; i++) {
|
|
1269
1611
|
const a = addrs[i];
|
|
1270
1612
|
const f = inAir.get(a);
|
|
@@ -1295,7 +1637,8 @@ function draw(dt) {
|
|
|
1295
1637
|
colour = u < 0.5 ? col.estate.get(f.from) || col.neutral : col.estate.get(f.to) || col.neutral;
|
|
1296
1638
|
est = u < 0.5 ? f.from : f.to;
|
|
1297
1639
|
// The trail: where it was a moment ago, fading, in the destination's colour.
|
|
1298
|
-
|
|
1640
|
+
// At the card level the cards fly cell to cell, not along the slots' path: no trail then.
|
|
1641
|
+
if (dotLayerA > 0.05 && !f.parent && rosterU < 0.5) {
|
|
1299
1642
|
ctx.strokeStyle = col.estate.get(f.to) || col.neutral;
|
|
1300
1643
|
ctx.lineCap = "round";
|
|
1301
1644
|
let prev = p;
|
|
@@ -1340,6 +1683,13 @@ function draw(dt) {
|
|
|
1340
1683
|
const tdE = td.get(est) ?? 0;
|
|
1341
1684
|
// Card centre -> slot -> disc, by the zoom.
|
|
1342
1685
|
const card = S.cards.get(a);
|
|
1686
|
+
// A resource the SVG has no card for grows into its roster card as it slides from its slot to its cell in its
|
|
1687
|
+
// estate's grid of cards (web/dots-cards.js).
|
|
1688
|
+
const u = card ? 0 : rosterU * (1 - tdE);
|
|
1689
|
+
if (u > 0.001) {
|
|
1690
|
+
const cell = cellOf(a, f, L, t, ease);
|
|
1691
|
+
if (cell) p = { x: lerp(p.x, cell.x, u), y: lerp(p.y, cell.y, u) };
|
|
1692
|
+
}
|
|
1343
1693
|
const d = discAt(est);
|
|
1344
1694
|
const slotPx = { x: sx(p.x), y: sy(p.y) };
|
|
1345
1695
|
const cardPx = card ? { x: vx(card.x), y: vy(card.y) } : slotPx;
|
|
@@ -1352,10 +1702,28 @@ function draw(dt) {
|
|
|
1352
1702
|
S.px[i] = q.x;
|
|
1353
1703
|
S.py[i] = q.y;
|
|
1354
1704
|
S.pvis[i] = vis > 0.2 ? 1 : 0;
|
|
1355
|
-
|
|
1705
|
+
const flying = f && f.ok && !reduced;
|
|
1706
|
+
const shape = u > 0.01 ? cardShape(q.x, q.y, u, { dotR: flying ? rDot * 1.6 : rDot, cardW: rcW, cardH: rcH }) : null;
|
|
1707
|
+
S.pw[i] = shape ? shape.w / 2 : 0;
|
|
1708
|
+
S.ph[i] = shape ? shape.h / 2 : 0;
|
|
1709
|
+
const margin = shape ? 20 + shape.w / 2 : 20;
|
|
1710
|
+
if (q.x < -margin || q.y < -margin || q.x > W + margin || q.y > H + margin) continue;
|
|
1356
1711
|
const g = glow.get(a);
|
|
1357
|
-
if (f || g) markLit(est);
|
|
1712
|
+
if (f || (g && !g.dim)) markLit(est);
|
|
1358
1713
|
if (vis <= 0.01) continue;
|
|
1714
|
+
if (shape) {
|
|
1715
|
+
drawRosterCard(ctx, a, shape, u, { vis, colour, glow: g, ring: rings.has(a), selected: a === S.selected, takeoff: flying ? (t - f.start) / (f.end - f.start) : 1 });
|
|
1716
|
+
continue;
|
|
1717
|
+
}
|
|
1718
|
+
// A cone plan's dimmed dot: faded, still drawn.
|
|
1719
|
+
if (g && g.dim) {
|
|
1720
|
+
ctx.globalAlpha = vis * 0.35;
|
|
1721
|
+
ctx.fillStyle = colour;
|
|
1722
|
+
ctx.beginPath();
|
|
1723
|
+
ctx.arc(q.x, q.y, rDot, 0, Math.PI * 2);
|
|
1724
|
+
ctx.fill();
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1359
1727
|
if (g) {
|
|
1360
1728
|
ctx.globalAlpha = vis * g.a * 0.6;
|
|
1361
1729
|
ctx.fillStyle = g.colour;
|
|
@@ -1363,7 +1731,6 @@ function draw(dt) {
|
|
|
1363
1731
|
ctx.arc(q.x, q.y, rDot * 2.6, 0, Math.PI * 2);
|
|
1364
1732
|
ctx.fill();
|
|
1365
1733
|
}
|
|
1366
|
-
const flying = f && f.ok && !reduced;
|
|
1367
1734
|
if (flying) {
|
|
1368
1735
|
// A dot in the air is lifted: larger, with a soft halo in the colour it is turning.
|
|
1369
1736
|
ctx.globalAlpha = vis * 0.25;
|
|
@@ -1414,6 +1781,7 @@ function draw(dt) {
|
|
|
1414
1781
|
}
|
|
1415
1782
|
}
|
|
1416
1783
|
}
|
|
1784
|
+
if (S.cellMoving) moving = true;
|
|
1417
1785
|
// Landings: a small pulse at the dot and a ripple along the nearest border.
|
|
1418
1786
|
for (const f of near) {
|
|
1419
1787
|
if (t < f.end || t > f.end + RIPPLE_MS) continue;
|
|
@@ -1429,8 +1797,14 @@ function draw(dt) {
|
|
|
1429
1797
|
ctx.strokeStyle = col.estate.get(f.to) || col.neutral;
|
|
1430
1798
|
ctx.globalAlpha = a * (1 - u);
|
|
1431
1799
|
ctx.lineWidth = 1.5;
|
|
1432
|
-
|
|
1433
|
-
|
|
1800
|
+
if (S.pw[i] > 0) {
|
|
1801
|
+
// A card's landing: its outline swells and fades.
|
|
1802
|
+
const grow = 2 + u * 10;
|
|
1803
|
+
roundRect(ctx, qx - S.pw[i] - grow, qy - S.ph[i] - grow, 2 * (S.pw[i] + grow), 2 * (S.ph[i] + grow), 6 + grow / 2);
|
|
1804
|
+
} else {
|
|
1805
|
+
ctx.beginPath();
|
|
1806
|
+
ctx.arc(qx, qy, rDot * (1.2 + u * 5), 0, Math.PI * 2);
|
|
1807
|
+
}
|
|
1434
1808
|
ctx.stroke();
|
|
1435
1809
|
}
|
|
1436
1810
|
const b = boxes.get(f.to);
|
|
@@ -1456,15 +1830,25 @@ function draw(dt) {
|
|
|
1456
1830
|
const qx = S.px[i];
|
|
1457
1831
|
const qy = S.py[i];
|
|
1458
1832
|
const u = Math.min(1, (t - f.end) / PULSE_MS);
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1833
|
+
if (S.pw[i] > 0) {
|
|
1834
|
+
// A refused card: its outline in the failure colour, so its words stay readable.
|
|
1835
|
+
const out = 2 + 3 * (1 - u);
|
|
1836
|
+
ctx.globalAlpha = dotLayerA * (0.6 + 0.4 * (1 - u));
|
|
1837
|
+
ctx.strokeStyle = col.degraded;
|
|
1838
|
+
ctx.lineWidth = 2.2;
|
|
1839
|
+
roundRect(ctx, qx - S.pw[i] - out, qy - S.ph[i] - out, 2 * (S.pw[i] + out), 2 * (S.ph[i] + out), 7);
|
|
1840
|
+
ctx.stroke();
|
|
1841
|
+
} else {
|
|
1842
|
+
ctx.globalAlpha = dotLayerA * (0.35 + 0.4 * (1 - u));
|
|
1843
|
+
ctx.fillStyle = col.degraded;
|
|
1844
|
+
ctx.beginPath();
|
|
1845
|
+
ctx.arc(qx, qy, rDot * (2.2 + 1.5 * (1 - u)), 0, Math.PI * 2);
|
|
1846
|
+
ctx.fill();
|
|
1847
|
+
ctx.globalAlpha = dotLayerA;
|
|
1848
|
+
ctx.beginPath();
|
|
1849
|
+
ctx.arc(qx, qy, rDot, 0, Math.PI * 2);
|
|
1850
|
+
ctx.fill();
|
|
1851
|
+
}
|
|
1468
1852
|
const b = boxes.get(owners.get(f.address) ?? scene.source);
|
|
1469
1853
|
if (b) {
|
|
1470
1854
|
const bp = boxPx(b);
|
|
@@ -1618,18 +2002,32 @@ function startKiosk() {
|
|
|
1618
2002
|
window.addEventListener("message", onMsg);
|
|
1619
2003
|
S.off.push(() => window.removeEventListener("message", onMsg));
|
|
1620
2004
|
// The director never moves while a person has the graph in hand.
|
|
1621
|
-
|
|
1622
|
-
if (S) S.userUntil = performance.now() + 8_000;
|
|
1623
|
-
};
|
|
1624
|
-
for (const ev of ["wheel", "mousedown", "touchstart"]) {
|
|
1625
|
-
S.host.addEventListener(ev, touched, { passive: true });
|
|
1626
|
-
S.off.push(() => S && S.host.removeEventListener(ev, touched));
|
|
1627
|
-
}
|
|
2005
|
+
watchViewer();
|
|
1628
2006
|
S.camAt = null;
|
|
1629
2007
|
play(true);
|
|
1630
2008
|
toParent({ type: "behold:dots-ready", source: S.name });
|
|
1631
2009
|
}
|
|
1632
2010
|
|
|
2011
|
+
/** A viewer has the camera: the director and the tour's framing wait until VIEWER_HOLD_MS after their last input, then ease back. */
|
|
2012
|
+
function viewerHold() {
|
|
2013
|
+
if (S) S.userUntil = performance.now() + VIEWER_HOLD_MS;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* The director never moves while a person has the graph in hand: every input that moves the camera holds it, a wheel
|
|
2018
|
+
* or a trackpad pinch (a wheel with ctrlKey), a touch and each move of a pinch, a press and each move of a drag.
|
|
2019
|
+
*/
|
|
2020
|
+
function watchViewer() {
|
|
2021
|
+
const host = S.host;
|
|
2022
|
+
const dragging = (e) => {
|
|
2023
|
+
if (e.buttons) viewerHold();
|
|
2024
|
+
};
|
|
2025
|
+
for (const [ev, f] of [["wheel", viewerHold], ["pointerdown", viewerHold], ["mousedown", viewerHold], ["touchstart", viewerHold], ["touchmove", viewerHold], ["pointermove", dragging]]) {
|
|
2026
|
+
host.addEventListener(ev, f, { passive: true });
|
|
2027
|
+
S.off.push(() => host.removeEventListener(ev, f));
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
|
|
1633
2031
|
/** A box in scene pitches, as the viewBox that frames it clear of the rail and the parent's caption. */
|
|
1634
2032
|
function frameBox(b) {
|
|
1635
2033
|
const { r, left, right } = band();
|
|
@@ -1645,8 +2043,11 @@ function frameBox(b) {
|
|
|
1645
2043
|
const bottom = S.insets.bottom + 8 + foot;
|
|
1646
2044
|
const aw = Math.max(40, r.width - left - right - 16);
|
|
1647
2045
|
const ah = Math.max(40, r.height - top - bottom);
|
|
1648
|
-
// Never so close that a card shows again: dots stay dots.
|
|
1649
|
-
|
|
2046
|
+
// Never so close that a card shows again: dots stay dots. Unless the whole shot fits with each roster card wide
|
|
2047
|
+
// enough to read its name (the rail's Cards mark): a few resources are framed as cards, in their estates' boxes.
|
|
2048
|
+
const f = frameNumbers(aw / bw, ah / bh);
|
|
2049
|
+
S.frameNums = f;
|
|
2050
|
+
const s = f.s;
|
|
1650
2051
|
const vw = r.width / s;
|
|
1651
2052
|
const vh = r.height / s;
|
|
1652
2053
|
const vx = bx + bw / 2 - (left + 8 + aw / 2) / s;
|
|
@@ -1654,23 +2055,26 @@ function frameBox(b) {
|
|
|
1654
2055
|
return [vx, vy, vw, vh];
|
|
1655
2056
|
}
|
|
1656
2057
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
return {
|
|
2058
|
+
/**
|
|
2059
|
+
* A tour light's glow on a dot or a card: a changed resource full and ringed; one the plan only planned, beside a
|
|
2060
|
+
* changed one, faint and dimmed; with nothing changed, every planned one lit alike.
|
|
2061
|
+
*/
|
|
2062
|
+
export function tourGlow(light, anyChanged, colour) {
|
|
2063
|
+
if (light.changed) return { colour, a: 1, ring: true, dim: false };
|
|
2064
|
+
return anyChanged ? { colour, a: 0.4, ring: false, dim: true } : { colour, a: 0.85, ring: false, dim: false };
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
/** The director's zoom and what it is made of, for frameBox and __dots.debug(). */
|
|
2068
|
+
function frameNumbers(fitW, fitH) {
|
|
2069
|
+
const fit = Math.min(fitW, fitH);
|
|
2070
|
+
const cardsAt = S.seedless && S.rc && S.rc.w > 0 && S.need > 0 ? (S.need * 1.1) / S.rc.w : null;
|
|
2071
|
+
const dotsCap = 20 / S.cardW;
|
|
2072
|
+
const small = smallStage();
|
|
2073
|
+
return { fit, cardsAt, dotsCap, small, need: S.need ?? null, rc: S.rc ?? null, gridK: S.gridK ?? null, s: directorScale({ fit, dotsCap, cardsAt, small }) };
|
|
1663
2074
|
}
|
|
1664
2075
|
|
|
1665
2076
|
function focusBox(focus) {
|
|
1666
|
-
|
|
1667
|
-
const now = sc.layoutAt(takeoffsBy(sc, S.t)).boxes;
|
|
1668
|
-
const fin = sc.layoutAt(sc.landing.length).boxes;
|
|
1669
|
-
const src = now.get(sc.source) || sc.layoutAt(0).boxes.get(sc.source);
|
|
1670
|
-
if (focus.kind === "all") return { x: 0, y: 0, w: sc.extent.w, h: sc.extent.h };
|
|
1671
|
-
if (focus.kind === "source" || focus.estate === sc.source) return src;
|
|
1672
|
-
// The estate receiving the flock, with the box it leaves, so the flight is in the shot.
|
|
1673
|
-
return unionBox(src, fin.get(focus.estate) || now.get(focus.estate));
|
|
2077
|
+
return focusRect(S.scene, focus, S.t);
|
|
1674
2078
|
}
|
|
1675
2079
|
|
|
1676
2080
|
function kioskTick(wall, dt) {
|
|
@@ -1780,13 +2184,7 @@ function startLive(kiosk) {
|
|
|
1780
2184
|
window.addEventListener("message", onMsg);
|
|
1781
2185
|
S.off.push(() => window.removeEventListener("message", onMsg));
|
|
1782
2186
|
// The director never moves while a person has the graph in hand.
|
|
1783
|
-
|
|
1784
|
-
if (S) S.userUntil = performance.now() + 8_000;
|
|
1785
|
-
};
|
|
1786
|
-
for (const ev of ["wheel", "mousedown", "touchstart"]) {
|
|
1787
|
-
S.host.addEventListener(ev, touched, { passive: true });
|
|
1788
|
-
S.off.push(() => S && S.host.removeEventListener(ev, touched));
|
|
1789
|
-
}
|
|
2187
|
+
watchViewer();
|
|
1790
2188
|
toParent({ type: "behold:dots-ready", source: S.name, live: true });
|
|
1791
2189
|
}
|
|
1792
2190
|
}
|
|
@@ -1826,7 +2224,7 @@ function takeLive(answer) {
|
|
|
1826
2224
|
S.show.t1 = now;
|
|
1827
2225
|
return;
|
|
1828
2226
|
}
|
|
1829
|
-
const scene =
|
|
2227
|
+
const scene = sceneFor(show, { sourceAspect: S.mbox.w / Math.max(1, S.mbox.h), ...labelRoom(S.host) }, S.seedless);
|
|
1830
2228
|
const n = show.roster.length;
|
|
1831
2229
|
const src = scene.sourceBox;
|
|
1832
2230
|
S.show = show;
|
|
@@ -1841,6 +2239,10 @@ function takeLive(answer) {
|
|
|
1841
2239
|
S.px = new Float32Array(n);
|
|
1842
2240
|
S.py = new Float32Array(n);
|
|
1843
2241
|
S.pvis = new Uint8Array(n);
|
|
2242
|
+
S.pw = new Float32Array(n);
|
|
2243
|
+
S.ph = new Float32Array(n);
|
|
2244
|
+
// A later read may name a type the first did not, and the boxes the cards fill are the new scene's.
|
|
2245
|
+
fitRosterCards();
|
|
1844
2246
|
S.col = readColours();
|
|
1845
2247
|
busy();
|
|
1846
2248
|
S.dirty = true;
|